[PATCH v2] USB: gadget: add maxpacket_limit field to struct usb_ep
This patch adds maxpacket_limit to struct usb_ep. This field contains maximum value of maxpacket supported by driver, and is set in driver probe. This value should be used by autoconfig() function, because value of field maxpacket is set to value from endpoint descriptor when endpoint becomes enabled. So when autoconfig() function will be called again for this endpoint, maxpacket value will contain wMaxPacketSize from descriptior instead of maximum packet size for this endpoint. For this reason this patch adds new field maxpacket_limit which contains value of maximum packet size (which defines maximum endpoint capabilities). This value is used in ep_matches() function used by autoconfig(). Value of maxpacket_limit should be set in UDC driver probe function, using usb_ep_set_maxpacket_limit() function, defined in gadget.h. This function set choosen value to both maxpacket_limit and maxpacket fields. This patch modifies UDC drivers by adding support for maxpacket_limit. Signed-off-by: Robert Baldyga r.bald...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- Hello, This is second version of this patch. I have added documentation for modifications in gadget.h, and modified dummy-hdc driver to make it supporting maxpacket_limit, which I missed in previous version od this patch. Best regards Robert Baldyga Samsung RD Institute Poland Changelog: v2: - add documentation for maxpacket_limit field in struct usb_ep and for usb_ep_set_maxpacket_limit() function - add maxpacket_limit support for dummy-hdc UDC driver v1: http://www.spinics.net/lists/linux-usb/msg99305.html drivers/usb/gadget/amd5536udc.c | 15 +-- drivers/usb/gadget/at91_udc.c | 16 drivers/usb/gadget/atmel_usba_udc.c |5 +++-- drivers/usb/gadget/bcm63xx_udc.c|4 ++-- drivers/usb/gadget/dummy_hcd.c |2 +- drivers/usb/gadget/epautoconf.c |6 +++--- drivers/usb/gadget/fotg210-udc.c|3 ++- drivers/usb/gadget/fsl_udc_core.c |5 +++-- drivers/usb/gadget/fusb300_udc.c|4 ++-- drivers/usb/gadget/goku_udc.c |4 ++-- drivers/usb/gadget/lpc32xx_udc.c|2 +- drivers/usb/gadget/m66592-udc.c |4 ++-- drivers/usb/gadget/mv_udc_core.c|4 ++-- drivers/usb/gadget/omap_udc.c |3 ++- drivers/usb/gadget/pch_udc.c|6 +++--- drivers/usb/gadget/pxa25x_udc.c |1 + drivers/usb/gadget/pxa27x_udc.c |5 - drivers/usb/gadget/r8a66597-udc.c |4 ++-- drivers/usb/gadget/s3c-hsotg.c |2 +- drivers/usb/gadget/s3c-hsudc.c |2 +- drivers/usb/gadget/s3c2410_udc.c|1 + include/linux/usb/gadget.h | 19 +++ 22 files changed, 74 insertions(+), 43 deletions(-) diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c index 54a1e29..f487e0e 100644 --- a/drivers/usb/gadget/amd5536udc.c +++ b/drivers/usb/gadget/amd5536udc.c @@ -446,7 +446,7 @@ static void ep_init(struct udc_regs __iomem *regs, struct udc_ep *ep) ep-ep.ops = udc_ep_ops; INIT_LIST_HEAD(ep-queue); - ep-ep.maxpacket = (u16) ~0; + usb_ep_set_maxpacket_limit(ep-ep,(u16) ~0); /* set NAK */ tmp = readl(ep-regs-ctl); tmp |= AMD_BIT(UDC_EPCTL_SNAK); @@ -1564,12 +1564,15 @@ static void udc_setup_endpoints(struct udc *dev) } /* EP0 max packet */ if (dev-gadget.speed == USB_SPEED_FULL) { - dev-ep[UDC_EP0IN_IX].ep.maxpacket = UDC_FS_EP0IN_MAX_PKT_SIZE; - dev-ep[UDC_EP0OUT_IX].ep.maxpacket = - UDC_FS_EP0OUT_MAX_PKT_SIZE; + usb_ep_set_maxpacket_limit(dev-ep[UDC_EP0IN_IX].ep, + UDC_FS_EP0IN_MAX_PKT_SIZE); + usb_ep_set_maxpacket_limit(dev-ep[UDC_EP0OUT_IX].ep, + UDC_FS_EP0OUT_MAX_PKT_SIZE); } else if (dev-gadget.speed == USB_SPEED_HIGH) { - dev-ep[UDC_EP0IN_IX].ep.maxpacket = UDC_EP0IN_MAX_PKT_SIZE; - dev-ep[UDC_EP0OUT_IX].ep.maxpacket = UDC_EP0OUT_MAX_PKT_SIZE; + usb_ep_set_maxpacket_limit(dev-ep[UDC_EP0IN_IX].ep, + UDC_EP0IN_MAX_PKT_SIZE); + usb_ep_set_maxpacket_limit(dev-ep[UDC_EP0OUT_IX].ep, + UDC_EP0OUT_MAX_PKT_SIZE); } /* diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index 4cc4fd6..0353b64 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c @@ -834,7 +834,7 @@ static void udc_reinit(struct at91_udc *udc) ep-ep.desc = NULL; ep-stopped = 0; ep-fifo_bank = 0; - ep-ep.maxpacket = ep-maxpacket; + usb_ep_set_maxpacket_limit(ep-ep, ep-maxpacket); ep-creg = (void __iomem *) udc-udp_baseaddr +
[PATCH v4 9/9] ARM: dts: add usb udc support to bcm281xx
Adds USB OTG/PHY and clock support to BCM281xx and enables UDC support on the bcm11351-brt and bcm28155-ap boards. Signed-off-by: Matt Porter mpor...@linaro.org Reviewed-by: Markus Mayer markus.ma...@linaro.org Reviewed-by: Tim Kryger tim.kry...@linaro.org --- arch/arm/boot/dts/bcm11351-brt.dts | 6 ++ arch/arm/boot/dts/bcm11351.dtsi| 18 ++ arch/arm/boot/dts/bcm28155-ap.dts | 8 3 files changed, 32 insertions(+) diff --git a/arch/arm/boot/dts/bcm11351-brt.dts b/arch/arm/boot/dts/bcm11351-brt.dts index 23cd16d..396b704 100644 --- a/arch/arm/boot/dts/bcm11351-brt.dts +++ b/arch/arm/boot/dts/bcm11351-brt.dts @@ -44,5 +44,11 @@ status = okay; }; + usbotg: usb@3f12 { + status = okay; + }; + usbphy: usb-phy@3f13 { + status = okay; + }; }; diff --git a/arch/arm/boot/dts/bcm11351.dtsi b/arch/arm/boot/dts/bcm11351.dtsi index 1246885..0fbb455 100644 --- a/arch/arm/boot/dts/bcm11351.dtsi +++ b/arch/arm/boot/dts/bcm11351.dtsi @@ -243,4 +243,22 @@ #clock-cells = 0; }; }; + + usbotg: usb@3f12 { + compatible = snps,dwc2; + reg = 0x3f12 0x1; + interrupts = GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH; + clocks = usb_otg_ahb_clk; + clock-names = otg; + phys = usbphy; + phy-names = usb2-phy; + status = disabled; + }; + + usbphy: usb-phy@3f13 { + compatible = brcm,kona-usb2-phy; + reg = 0x3f13 0x28; + #phy-cells = 0; + status = disabled; + }; }; diff --git a/arch/arm/boot/dts/bcm28155-ap.dts b/arch/arm/boot/dts/bcm28155-ap.dts index 08e47c2..a3bc436 100644 --- a/arch/arm/boot/dts/bcm28155-ap.dts +++ b/arch/arm/boot/dts/bcm28155-ap.dts @@ -43,4 +43,12 @@ cd-gpios = gpio 14 0; status = okay; }; + + usbotg: usb@3f12 { + status = okay; + }; + + usbphy: usb-phy@3f13 { + status = okay; + }; }; -- 1.8.4 -- 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 6/9] usb: gadget: s3c-hsotg: get phy bus width from phy subsystem
Adds support for querying the phy bus width from the generic phy subsystem. Configure UTMI bus width in GUSBCFG based on this value. Signed-off-by: Matt Porter mpor...@linaro.org --- drivers/usb/gadget/s3c-hsotg.c | 14 +- drivers/usb/gadget/s3c-hsotg.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index e9683c2..168aaa9 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c @@ -144,6 +144,7 @@ struct s3c_hsotg_ep { * @regs: The memory area mapped for accessing registers. * @irq: The IRQ number we are using * @supplies: Definition of USB power supplies + * @phyif: PHY interface width * @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos. * @num_of_eps: Number of available EPs (excluding EP0) * @debug_root: root directrory for debugfs. @@ -171,6 +172,7 @@ struct s3c_hsotg { struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsotg_supply_names)]; + u32 phyif; unsigned intdedicated_fifos:1; unsigned char num_of_eps; @@ -2276,7 +2278,7 @@ static void s3c_hsotg_core_init(struct s3c_hsotg *hsotg) */ /* set the PLL on, remove the HNP/SRP and set the PHY */ - writel(GUSBCFG_PHYIf16 | GUSBCFG_TOutCal(7) | + writel(hsotg-phyif | GUSBCFG_TOutCal(7) | (0x5 10), hsotg-regs + GUSBCFG); s3c_hsotg_init_fifo(hsotg); @@ -3621,6 +3623,16 @@ static int s3c_hsotg_probe(struct platform_device *pdev) goto err_supplies; } + /* Set default UTMI width */ + hsotg-phyif = GUSBCFG_PHYIf16; + + /* +* If using the generic PHY framework, check if the PHY bus +* width is 8-bit and set the phyif appropriately. +*/ + if (hsotg-phy (phy_get_bus_width(phy) == 8)) + hsotg-phyif = GUSBCFG_PHYIf8; + if (hsotg-phy) phy_init(hsotg-phy); diff --git a/drivers/usb/gadget/s3c-hsotg.h b/drivers/usb/gadget/s3c-hsotg.h index d650b12..85f549f 100644 --- a/drivers/usb/gadget/s3c-hsotg.h +++ b/drivers/usb/gadget/s3c-hsotg.h @@ -55,6 +55,7 @@ #define GUSBCFG_HNPCap (1 9) #define GUSBCFG_SRPCap (1 8) #define GUSBCFG_PHYIf16(1 3) +#define GUSBCFG_PHYIf8 (0 3) #define GUSBCFG_TOutCal_MASK (0x7 0) #define GUSBCFG_TOutCal_SHIFT (0) #define GUSBCFG_TOutCal_LIMIT (0x7) -- 1.8.4 -- 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 8/9] phy: add Broadcom Kona USB2 PHY driver
Add a driver for the internal Broadcom Kona USB 2.0 PHY found on the BCM281xx family of SoCs. Signed-off-by: Matt Porter mpor...@linaro.org --- drivers/phy/Kconfig | 6 ++ drivers/phy/Makefile| 1 + drivers/phy/phy-bcm-kona-usb2.c | 158 3 files changed, 165 insertions(+) create mode 100644 drivers/phy/phy-bcm-kona-usb2.c diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index a344f3d..2e87fa8 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -51,4 +51,10 @@ config PHY_EXYNOS_DP_VIDEO help Support for Display Port PHY found on Samsung EXYNOS SoCs. +config BCM_KONA_USB2_PHY + tristate Broadcom Kona USB2 PHY Driver + depends on GENERIC_PHY + help + Enable this to support the Broadcom Kona USB 2.0 PHY. + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index d0caae9..c447f1a 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -3,6 +3,7 @@ # obj-$(CONFIG_GENERIC_PHY) += phy-core.o +obj-$(CONFIG_BCM_KONA_USB2_PHY)+= phy-bcm-kona-usb2.o obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO) += phy-exynos-dp-video.o obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)+= phy-exynos-mipi-video.o obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o diff --git a/drivers/phy/phy-bcm-kona-usb2.c b/drivers/phy/phy-bcm-kona-usb2.c new file mode 100644 index 000..0046781 --- /dev/null +++ b/drivers/phy/phy-bcm-kona-usb2.c @@ -0,0 +1,158 @@ +/* + * phy-bcm-kona-usb2.c - Broadcom Kona USB2 Phy Driver + * + * Copyright (C) 2013 Linaro Limited + * Matt Porter mpor...@linaro.org + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include linux/clk.h +#include linux/delay.h +#include linux/err.h +#include linux/io.h +#include linux/module.h +#include linux/of.h +#include linux/phy/phy.h +#include linux/platform_device.h + +#define OTGCTL (0) +#define OTGCTL_OTGSTAT2BIT(31) +#define OTGCTL_OTGSTAT1BIT(30) +#define OTGCTL_PRST_N_SW BIT(11) +#define OTGCTL_HRESET_NBIT(10) +#define OTGCTL_UTMI_LINE_STATE1BIT(9) +#define OTGCTL_UTMI_LINE_STATE0BIT(8) + +#define P1CTL (8) +#define P1CTL_SOFT_RESET BIT(1) +#define P1CTL_NON_DRIVING BIT(0) + +struct bcm_kona_usb { + void __iomem *regs; +}; + +static void bcm_kona_usb_phy_power(struct bcm_kona_usb *phy, int on) +{ + u32 val; + + val = readl(phy-regs + OTGCTL); + if (on) { + /* Configure and power PHY */ + val = ~(OTGCTL_OTGSTAT2 | OTGCTL_OTGSTAT1 | +OTGCTL_UTMI_LINE_STATE1 | OTGCTL_UTMI_LINE_STATE0); + val |= OTGCTL_PRST_N_SW | OTGCTL_HRESET_N; + } else { + val = ~(OTGCTL_PRST_N_SW | OTGCTL_HRESET_N); + } + writel(val, phy-regs + OTGCTL); +} + +static int bcm_kona_usb_phy_init(struct phy *gphy) +{ + struct bcm_kona_usb *phy = phy_get_drvdata(gphy); + u32 val; + + /* Soft reset PHY */ + val = readl(phy-regs + P1CTL); + val = ~P1CTL_NON_DRIVING; + val |= P1CTL_SOFT_RESET; + writel(val, phy-regs + P1CTL); + writel(val ~P1CTL_SOFT_RESET, phy-regs + P1CTL); + /* Reset needs to be asserted for 2ms */ + mdelay(2); + writel(val | P1CTL_SOFT_RESET, phy-regs + P1CTL); + + return 0; +} + +static int bcm_kona_usb_phy_power_on(struct phy *gphy) +{ + struct bcm_kona_usb *phy = phy_get_drvdata(gphy); + + bcm_kona_usb_phy_power(phy, 1); + + return 0; +} + +static int bcm_kona_usb_phy_power_off(struct phy *gphy) +{ + struct bcm_kona_usb *phy = phy_get_drvdata(gphy); + + bcm_kona_usb_phy_power(phy, 0); + + return 0; +} + +static struct phy_ops ops = { + .init = bcm_kona_usb_phy_init, + .power_on = bcm_kona_usb_phy_power_on, + .power_off = bcm_kona_usb_phy_power_off, + .owner = THIS_MODULE, +}; + +static int bcm_kona_usb2_probe(struct platform_device *pdev) +{ + struct device *dev = pdev-dev; + struct bcm_kona_usb *phy; + struct resource *res; + struct phy *gphy; + struct phy_provider *phy_provider; + + phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL); + if (!phy) + return -ENOMEM; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + phy-regs = devm_ioremap_resource(pdev-dev, res); + if (IS_ERR(phy-regs)) + return
[PATCH v4 3/9] usb: gadget: s3c-hsotg: enable build for other platforms
Remove unused Samsung-specific machine include and Kconfig dependency on S3C. Signed-off-by: Matt Porter mpor...@linaro.org Reviewed-by: Markus Mayer markus.ma...@linaro.org Reviewed-by: Tim Kryger tim.kry...@linaro.org --- drivers/usb/gadget/Kconfig | 7 +++ drivers/usb/gadget/s3c-hsotg.c | 2 -- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index a91e642..970bd1a 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -294,11 +294,10 @@ config USB_PXA27X gadget drivers to also be dynamically linked. config USB_S3C_HSOTG - tristate S3C HS/OtG USB Device controller - depends on S3C_DEV_USB_HSOTG + tristate Designware/S3C HS/OtG USB Device controller help - The Samsung S3C64XX USB2.0 high-speed gadget controller - integrated into the S3C64XX series SoC. + The Designware USB2.0 high-speed gadget controller + integrated into the S3C64XX and BCM281xx series SoC. config USB_S3C2410 tristate S3C2410 USB Device Controller diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index 33eb690..8ceb5ef 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c @@ -37,8 +37,6 @@ #include linux/usb/phy.h #include linux/platform_data/s3c-hsotg.h -#include mach/map.h - #include s3c-hsotg.h static const char * const s3c_hsotg_supply_names[] = { -- 1.8.4 -- 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 4/9] usb: gadget: s3c-hsotg: add snps,dwc2 compatible string
Enable support for the dwc2 binding. Signed-off-by: Matt Porter mpor...@linaro.org --- drivers/usb/gadget/s3c-hsotg.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index 8ceb5ef..7c5d8bd 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c @@ -3727,6 +3727,7 @@ static int s3c_hsotg_remove(struct platform_device *pdev) #ifdef CONFIG_OF static const struct of_device_id s3c_hsotg_of_ids[] = { { .compatible = samsung,s3c6400-hsotg, }, + { .compatible = snps,dwc2, }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, s3c_hsotg_of_ids); -- 1.8.4 -- 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 0/9] USB Device Controller support for BCM281xx
Changes since v3: - Rebased on 3.13-rc3 - Move struct phy bus_width attribute back into struct phy_attrs - Fix build issue on !GENERIC_PHY - Update dwc2 binding to reflect optional phy properties - Rename bcm-kona-phy.txt binding to bcm-phy.txt - Reorder bcm kona phy includes and use bitops - phy-names changed to usb2-phy to match updated s3c-hsotg generic phy-ification series Changes since v2: - Rebased on 3.13-rc1 - Fix braces in phy_get_bus_width()/phy_set_bus_width() - Drop generic phy conversion to use the same support from the Exynos generic phy conversion series - Modify dts support to match the device phy name required in the v3 Exynos generic phy conversion - Add s3c-hsotg phy_init/phy_exit support - Fix typo on reg property in kona phy binding - Replace phy driver reg struct with offset defines - Move phy soft reset to phy driver init - Fix dts node names to match ePAPR conventions Changes since v1: - Convert USB phy driver to generic phy subsystem - Add phy bus width apis - Drop dwc2 phy bus width DT property in favor of querying the phy provider for bus width - Add generic phy/clock properties to dwc2 DT binding - Add generic phy subsystem support to s3c-hsotg with the existing usb phy and pdata phy methods as a fallback - Split bindings out to separate patches to match the latest DT binding review guidelines This series adds USB Device Controller support for the Broadcom BCM281xx family of parts. BCM281xx contains a DWC2 OTG block and s3c-hsotg is used to support UDC operation. Part 1 adds phy bus width support to the generic phy subsystem Parts 2-6 allows s3c-hsotg to build on non-Samsung platforms, supports the dwc2 binding, adds phy_init/phy_exit support, and supports fetching phy bus width using the generic phy layer. Parts 7-8 add a generic phy binding and driver for the BCM Kona USB PHY. Part 9 adds the DT nodes to enable UDC support on both BCM281xx boards in the kernel. This series depends on: - Update Kona drivers to use clocks v4 series https://lkml.org/lkml/2013/12/5/508 - Add new Exynos USB 2.0 PHY driver v4 series https://lkml.org/lkml/2013/12/5/166 Matt Porter (9): phy: add phy_get_bus_width()/phy_set_bus_width() calls staging: dwc2: update DT binding to add generic clock/phy properties usb: gadget: s3c-hsotg: enable build for other platforms usb: gadget: s3c-hsotg: add snps,dwc2 compatible string usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support usb: gadget: s3c-hsotg: get phy bus width from phy subsystem phy: add Broadcom Kona USB2 PHY DT binding phy: add Broadcom Kona USB2 PHY driver ARM: dts: add usb udc support to bcm281xx Documentation/devicetree/bindings/phy/bcm-phy.txt | 15 ++ Documentation/devicetree/bindings/staging/dwc2.txt | 12 ++ arch/arm/boot/dts/bcm11351-brt.dts | 6 + arch/arm/boot/dts/bcm11351.dtsi| 18 +++ arch/arm/boot/dts/bcm28155-ap.dts | 8 ++ drivers/phy/Kconfig| 6 + drivers/phy/Makefile | 1 + drivers/phy/phy-bcm-kona-usb2.c| 158 + drivers/usb/gadget/Kconfig | 7 +- drivers/usb/gadget/s3c-hsotg.c | 22 ++- drivers/usb/gadget/s3c-hsotg.h | 1 + include/linux/phy/phy.h| 28 12 files changed, 275 insertions(+), 7 deletions(-) create mode 100644 Documentation/devicetree/bindings/phy/bcm-phy.txt create mode 100644 drivers/phy/phy-bcm-kona-usb2.c -- 1.8.4 -- 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/9] staging: dwc2: update DT binding to add generic clock/phy properties
dwc2/s3c-hsotg require a single clock to be specified and optionally a generic phy. On the s3c-hsotg driver old style USB phy support is present as a fallback so the generic phy properties are optional. Signed-off-by: Matt Porter mpor...@linaro.org Acked-by: Kishon Vijay Abraham I kis...@ti.com --- Documentation/devicetree/bindings/staging/dwc2.txt | 12 1 file changed, 12 insertions(+) diff --git a/Documentation/devicetree/bindings/staging/dwc2.txt b/Documentation/devicetree/bindings/staging/dwc2.txt index 1a1b7cf..a1753ed 100644 --- a/Documentation/devicetree/bindings/staging/dwc2.txt +++ b/Documentation/devicetree/bindings/staging/dwc2.txt @@ -5,6 +5,14 @@ Required properties: - compatible : snps,dwc2 - reg : Should contain 1 register range (address and length) - interrupts : Should contain 1 interrupt +- clocks: clock provider specifier +- clock-names: shall be otg +Refer to clk/clock-bindings.txt for generic clock consumer properties + +Optional properties: +- phys: phy provider specifier +- phy-names: shall be device +Refer to phy/phy-bindings.txt for generic phy consumer properties Example: @@ -12,4 +20,8 @@ Example: compatible = ralink,rt3050-usb, snps,dwc2; reg = 0x101c 4; interrupts = 18; + clocks = usb_otg_ahb_clk; + clock-names = otg; + phys = usbphy; + phy-names = usb2-phy; }; -- 1.8.4 -- 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/9] phy: add phy_get_bus_width()/phy_set_bus_width() calls
This adds a pair of APIs that allows the generic PHY subsystem to provide information on the PHY bus width. The PHY provider driver may use phy_set_bus_width() to set the bus width that the PHY supports. The controller driver may then use phy_get_bus_width() to fetch the PHY bus width in order to properly configure the controller. Signed-off-by: Matt Porter mpor...@linaro.org --- include/linux/phy/phy.h | 28 1 file changed, 28 insertions(+) diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 6d72269..a0dcf2d 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -38,6 +38,14 @@ struct phy_ops { }; /** + * struct phy_attrs - represents phy attributes + * @bus_width: Data path width implemented by PHY + */ +struct phy_attrs { + u32 bus_width; +}; + +/** * struct phy - represents the phy device * @dev: phy device * @id: id of the phy device @@ -46,6 +54,7 @@ struct phy_ops { * @mutex: mutex to protect phy_ops * @init_count: used to protect when the PHY is used by multiple consumers * @power_count: used to protect when the PHY is used by multiple consumers + * @phy_attrs: used to specify PHY specific attributes */ struct phy { struct device dev; @@ -55,6 +64,7 @@ struct phy { struct mutexmutex; int init_count; int power_count; + struct phy_attrsattrs; }; /** @@ -127,6 +137,14 @@ int phy_init(struct phy *phy); int phy_exit(struct phy *phy); int phy_power_on(struct phy *phy); int phy_power_off(struct phy *phy); +static inline u32 phy_get_bus_width(struct phy *phy) +{ + return phy-attrs.bus_width; +} +static inline void phy_set_bus_width(struct phy *phy, u32 bus_width) +{ + phy-attrs.bus_width = bus_width; +} struct phy *phy_get(struct device *dev, const char *string); struct phy *devm_phy_get(struct device *dev, const char *string); void phy_put(struct phy *phy); @@ -199,6 +217,16 @@ static inline int phy_power_off(struct phy *phy) return -ENOSYS; } +static inline u32 phy_get_bus_width(struct phy *phy) +{ + return -ENOSYS; +} + +static inline void phy_set_bus_width(struct phy *phy, u32 bus_width) +{ + return; +} + static inline struct phy *phy_get(struct device *dev, const char *string) { return ERR_PTR(-ENOSYS); -- 1.8.4 -- 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 5/9] usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support
If a generic phy is present, call phy_init()/phy_exit(). This supports generic phys that must be soft reset before power on. Signed-off-by: Matt Porter mpor...@linaro.org --- drivers/usb/gadget/s3c-hsotg.c | 5 + 1 file changed, 5 insertions(+) diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index 7c5d8bd..e9683c2 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c @@ -3621,6 +3621,9 @@ static int s3c_hsotg_probe(struct platform_device *pdev) goto err_supplies; } + if (hsotg-phy) + phy_init(hsotg-phy); + /* usb phy enable */ s3c_hsotg_phy_enable(hsotg); @@ -3714,6 +3717,8 @@ static int s3c_hsotg_remove(struct platform_device *pdev) } s3c_hsotg_phy_disable(hsotg); + if (hsotg-phy) + phy_exit(hsotg-phy); clk_disable_unprepare(hsotg-clk); return 0; -- 1.8.4 -- 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 7/9] phy: add Broadcom Kona USB2 PHY DT binding
Add a binding that describes the Broadcom Kona USB2 PHY found on the BCM281xx family of SoCs. Signed-off-by: Matt Porter mpor...@linaro.org Acked-by: Kishon Vijay Abraham I kis...@ti.com --- Documentation/devicetree/bindings/phy/bcm-phy.txt | 15 +++ 1 file changed, 15 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/bcm-phy.txt diff --git a/Documentation/devicetree/bindings/phy/bcm-phy.txt b/Documentation/devicetree/bindings/phy/bcm-phy.txt new file mode 100644 index 000..3dc8b3d --- /dev/null +++ b/Documentation/devicetree/bindings/phy/bcm-phy.txt @@ -0,0 +1,15 @@ +BROADCOM KONA USB2 PHY + +Required properties: + - compatible: brcm,kona-usb2-phy + - reg: offset and length of the PHY registers + - #phy-cells: must be 0 +Refer to phy/phy-bindings.txt for the generic PHY binding properties + +Example: + + usbphy: usb-phy@3f13 { + compatible = brcm,kona-usb2-phy; + reg = 0x3f13 0x28; + #phy-cells = 0; + }; -- 1.8.4 -- 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/9] phy: add phy_get_bus_width()/phy_set_bus_width() calls
On Thu, Dec 12, 2013 at 11:27:15AM +, Russell King wrote: On Thu, Dec 12, 2013 at 06:18:29AM -0500, Matt Porter wrote: /** + * struct phy_attrs - represents phy attributes + * @bus_width: Data path width implemented by PHY + */ +struct phy_attrs { + u32 bus_width; Why u32? Kishon suggested it and I changed it on this rev...forgetting about the error path below. int phy_power_off(struct phy *phy); +static inline u32 phy_get_bus_width(struct phy *phy) +{ + return phy-attrs.bus_width; ... +static inline u32 phy_get_bus_width(struct phy *phy) +{ + return -ENOSYS; Why u32, especially as you're returning a negative number here. If the bus width is a small integer (I'm assuming you don't have up to 2^30 bus signals) then what's wrong with it being an 'int' ? Yes, very correct...it's expected to always be a small positive integer value or zero (when not populated as it's optional). I agree it should go back to 'int' especially due to the negative value when GENERIC_PHY isn't enabled. -Matt -- 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 v5 5/9] usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support
If a generic phy is present, call phy_init()/phy_exit(). This supports generic phys that must be soft reset before power on. Signed-off-by: Matt Porter mpor...@linaro.org --- drivers/usb/gadget/s3c-hsotg.c | 5 + 1 file changed, 5 insertions(+) diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index 7c5d8bd..e9683c2 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c @@ -3621,6 +3621,9 @@ static int s3c_hsotg_probe(struct platform_device *pdev) goto err_supplies; } + if (hsotg-phy) + phy_init(hsotg-phy); + /* usb phy enable */ s3c_hsotg_phy_enable(hsotg); @@ -3714,6 +3717,8 @@ static int s3c_hsotg_remove(struct platform_device *pdev) } s3c_hsotg_phy_disable(hsotg); + if (hsotg-phy) + phy_exit(hsotg-phy); clk_disable_unprepare(hsotg-clk); return 0; -- 1.8.4 -- 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 v5 6/9] usb: gadget: s3c-hsotg: get phy bus width from phy subsystem
Adds support for querying the phy bus width from the generic phy subsystem. Configure UTMI bus width in GUSBCFG based on this value. Signed-off-by: Matt Porter mpor...@linaro.org --- drivers/usb/gadget/s3c-hsotg.c | 14 +- drivers/usb/gadget/s3c-hsotg.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index e9683c2..168aaa9 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c @@ -144,6 +144,7 @@ struct s3c_hsotg_ep { * @regs: The memory area mapped for accessing registers. * @irq: The IRQ number we are using * @supplies: Definition of USB power supplies + * @phyif: PHY interface width * @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos. * @num_of_eps: Number of available EPs (excluding EP0) * @debug_root: root directrory for debugfs. @@ -171,6 +172,7 @@ struct s3c_hsotg { struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsotg_supply_names)]; + u32 phyif; unsigned intdedicated_fifos:1; unsigned char num_of_eps; @@ -2276,7 +2278,7 @@ static void s3c_hsotg_core_init(struct s3c_hsotg *hsotg) */ /* set the PLL on, remove the HNP/SRP and set the PHY */ - writel(GUSBCFG_PHYIf16 | GUSBCFG_TOutCal(7) | + writel(hsotg-phyif | GUSBCFG_TOutCal(7) | (0x5 10), hsotg-regs + GUSBCFG); s3c_hsotg_init_fifo(hsotg); @@ -3621,6 +3623,16 @@ static int s3c_hsotg_probe(struct platform_device *pdev) goto err_supplies; } + /* Set default UTMI width */ + hsotg-phyif = GUSBCFG_PHYIf16; + + /* +* If using the generic PHY framework, check if the PHY bus +* width is 8-bit and set the phyif appropriately. +*/ + if (hsotg-phy (phy_get_bus_width(phy) == 8)) + hsotg-phyif = GUSBCFG_PHYIf8; + if (hsotg-phy) phy_init(hsotg-phy); diff --git a/drivers/usb/gadget/s3c-hsotg.h b/drivers/usb/gadget/s3c-hsotg.h index d650b12..85f549f 100644 --- a/drivers/usb/gadget/s3c-hsotg.h +++ b/drivers/usb/gadget/s3c-hsotg.h @@ -55,6 +55,7 @@ #define GUSBCFG_HNPCap (1 9) #define GUSBCFG_SRPCap (1 8) #define GUSBCFG_PHYIf16(1 3) +#define GUSBCFG_PHYIf8 (0 3) #define GUSBCFG_TOutCal_MASK (0x7 0) #define GUSBCFG_TOutCal_SHIFT (0) #define GUSBCFG_TOutCal_LIMIT (0x7) -- 1.8.4 -- 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 v5 7/9] phy: add Broadcom Kona USB2 PHY DT binding
Add a binding that describes the Broadcom Kona USB2 PHY found on the BCM281xx family of SoCs. Signed-off-by: Matt Porter mpor...@linaro.org Acked-by: Kishon Vijay Abraham I kis...@ti.com --- Documentation/devicetree/bindings/phy/bcm-phy.txt | 15 +++ 1 file changed, 15 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/bcm-phy.txt diff --git a/Documentation/devicetree/bindings/phy/bcm-phy.txt b/Documentation/devicetree/bindings/phy/bcm-phy.txt new file mode 100644 index 000..3dc8b3d --- /dev/null +++ b/Documentation/devicetree/bindings/phy/bcm-phy.txt @@ -0,0 +1,15 @@ +BROADCOM KONA USB2 PHY + +Required properties: + - compatible: brcm,kona-usb2-phy + - reg: offset and length of the PHY registers + - #phy-cells: must be 0 +Refer to phy/phy-bindings.txt for the generic PHY binding properties + +Example: + + usbphy: usb-phy@3f13 { + compatible = brcm,kona-usb2-phy; + reg = 0x3f13 0x28; + #phy-cells = 0; + }; -- 1.8.4 -- 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 v5 2/9] staging: dwc2: update DT binding to add generic clock/phy properties
dwc2/s3c-hsotg require a single clock to be specified and optionally a generic phy. On the s3c-hsotg driver old style USB phy support is present as a fallback so the generic phy properties are optional. Signed-off-by: Matt Porter mpor...@linaro.org Acked-by: Kishon Vijay Abraham I kis...@ti.com --- Documentation/devicetree/bindings/staging/dwc2.txt | 12 1 file changed, 12 insertions(+) diff --git a/Documentation/devicetree/bindings/staging/dwc2.txt b/Documentation/devicetree/bindings/staging/dwc2.txt index 1a1b7cf..a1753ed 100644 --- a/Documentation/devicetree/bindings/staging/dwc2.txt +++ b/Documentation/devicetree/bindings/staging/dwc2.txt @@ -5,6 +5,14 @@ Required properties: - compatible : snps,dwc2 - reg : Should contain 1 register range (address and length) - interrupts : Should contain 1 interrupt +- clocks: clock provider specifier +- clock-names: shall be otg +Refer to clk/clock-bindings.txt for generic clock consumer properties + +Optional properties: +- phys: phy provider specifier +- phy-names: shall be device +Refer to phy/phy-bindings.txt for generic phy consumer properties Example: @@ -12,4 +20,8 @@ Example: compatible = ralink,rt3050-usb, snps,dwc2; reg = 0x101c 4; interrupts = 18; + clocks = usb_otg_ahb_clk; + clock-names = otg; + phys = usbphy; + phy-names = usb2-phy; }; -- 1.8.4 -- 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 v5 1/9] phy: add phy_get_bus_width()/phy_set_bus_width() calls
This adds a pair of APIs that allows the generic PHY subsystem to provide information on the PHY bus width. The PHY provider driver may use phy_set_bus_width() to set the bus width that the PHY supports. The controller driver may then use phy_get_bus_width() to fetch the PHY bus width in order to properly configure the controller. Signed-off-by: Matt Porter mpor...@linaro.org --- include/linux/phy/phy.h | 28 1 file changed, 28 insertions(+) diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 6d72269..e273e5a 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -38,6 +38,14 @@ struct phy_ops { }; /** + * struct phy_attrs - represents phy attributes + * @bus_width: Data path width implemented by PHY + */ +struct phy_attrs { + u32 bus_width; +}; + +/** * struct phy - represents the phy device * @dev: phy device * @id: id of the phy device @@ -46,6 +54,7 @@ struct phy_ops { * @mutex: mutex to protect phy_ops * @init_count: used to protect when the PHY is used by multiple consumers * @power_count: used to protect when the PHY is used by multiple consumers + * @phy_attrs: used to specify PHY specific attributes */ struct phy { struct device dev; @@ -55,6 +64,7 @@ struct phy { struct mutexmutex; int init_count; int power_count; + struct phy_attrsattrs; }; /** @@ -127,6 +137,14 @@ int phy_init(struct phy *phy); int phy_exit(struct phy *phy); int phy_power_on(struct phy *phy); int phy_power_off(struct phy *phy); +static inline int phy_get_bus_width(struct phy *phy) +{ + return phy-attrs.bus_width; +} +static inline void phy_set_bus_width(struct phy *phy, int bus_width) +{ + phy-attrs.bus_width = bus_width; +} struct phy *phy_get(struct device *dev, const char *string); struct phy *devm_phy_get(struct device *dev, const char *string); void phy_put(struct phy *phy); @@ -199,6 +217,16 @@ static inline int phy_power_off(struct phy *phy) return -ENOSYS; } +static inline int phy_get_bus_width(struct phy *phy) +{ + return -ENOSYS; +} + +static inline void phy_set_bus_width(struct phy *phy, int bus_width) +{ + return; +} + static inline struct phy *phy_get(struct device *dev, const char *string) { return ERR_PTR(-ENOSYS); -- 1.8.4 -- 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 v5 0/9] USB Device Controller support for BCM281xx
Changes since v4: - phy_set/get_bus_width now use an int for bus_width Changes since v3: - Rebased on 3.13-rc3 - Move struct phy bus_width attribute back into struct phy_attrs - Fix build issue on !GENERIC_PHY - Update dwc2 binding to reflect optional phy properties - Rename bcm-kona-phy.txt binding to bcm-phy.txt - Reorder bcm kona phy includes and use bitops - phy-names changed to usb2-phy to match updated s3c-hsotg generic phy-ification series Changes since v2: - Rebased on 3.13-rc1 - Fix braces in phy_get_bus_width()/phy_set_bus_width() - Drop generic phy conversion to use the same support from the Exynos generic phy conversion series - Modify dts support to match the device phy name required in the v3 Exynos generic phy conversion - Add s3c-hsotg phy_init/phy_exit support - Fix typo on reg property in kona phy binding - Replace phy driver reg struct with offset defines - Move phy soft reset to phy driver init - Fix dts node names to match ePAPR conventions Changes since v1: - Convert USB phy driver to generic phy subsystem - Add phy bus width apis - Drop dwc2 phy bus width DT property in favor of querying the phy provider for bus width - Add generic phy/clock properties to dwc2 DT binding - Add generic phy subsystem support to s3c-hsotg with the existing usb phy and pdata phy methods as a fallback - Split bindings out to separate patches to match the latest DT binding review guidelines This series adds USB Device Controller support for the Broadcom BCM281xx family of parts. BCM281xx contains a DWC2 OTG block and s3c-hsotg is used to support UDC operation. Part 1 adds phy bus width support to the generic phy subsystem Parts 2-6 allows s3c-hsotg to build on non-Samsung platforms, supports the dwc2 binding, adds phy_init/phy_exit support, and supports fetching phy bus width using the generic phy layer. Parts 7-8 add a generic phy binding and driver for the BCM Kona USB PHY. Part 9 adds the DT nodes to enable UDC support on both BCM281xx boards in the kernel. This series depends on: - Update Kona drivers to use clocks v4 series https://lkml.org/lkml/2013/12/5/508 - Add new Exynos USB 2.0 PHY driver v4 series https://lkml.org/lkml/2013/12/5/166 Matt Porter (9): phy: add phy_get_bus_width()/phy_set_bus_width() calls staging: dwc2: update DT binding to add generic clock/phy properties usb: gadget: s3c-hsotg: enable build for other platforms usb: gadget: s3c-hsotg: add snps,dwc2 compatible string usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support usb: gadget: s3c-hsotg: get phy bus width from phy subsystem phy: add Broadcom Kona USB2 PHY DT binding phy: add Broadcom Kona USB2 PHY driver ARM: dts: add usb udc support to bcm281xx Documentation/devicetree/bindings/phy/bcm-phy.txt | 15 ++ Documentation/devicetree/bindings/staging/dwc2.txt | 12 ++ arch/arm/boot/dts/bcm11351-brt.dts | 6 + arch/arm/boot/dts/bcm11351.dtsi| 18 +++ arch/arm/boot/dts/bcm28155-ap.dts | 8 ++ drivers/phy/Kconfig| 6 + drivers/phy/Makefile | 1 + drivers/phy/phy-bcm-kona-usb2.c| 158 + drivers/usb/gadget/Kconfig | 7 +- drivers/usb/gadget/s3c-hsotg.c | 22 ++- drivers/usb/gadget/s3c-hsotg.h | 1 + include/linux/phy/phy.h| 28 12 files changed, 275 insertions(+), 7 deletions(-) create mode 100644 Documentation/devicetree/bindings/phy/bcm-phy.txt create mode 100644 drivers/phy/phy-bcm-kona-usb2.c -- 1.8.4 -- 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: core: Add warm reset while reset-resuming SuperSpeed HUBs
On Wed, 11 Dec 2013, Julius Werner wrote: ...although, the spec says that it does not wait for the port resets to complete. As far as I can see re-issuing a warm reset and waiting is the only way to guarantee the core times the recovery. Presumably the portstatus debounce in hub_activate() mitigates this, but that 100ms is less than a full reset timeout. It's definitely not just a timing issue for us. I can't reproduce all the same cases as Vikas, but when I attach a USB analyzer to the ones I do see the host controller doesn't even start sending a reset. The xHCI spec requires that when the xHCI host is reset, a USB reset is driven down the USB 3.0 ports. If hot reset fails, the port may migrate to warm reset. See table 32 in the xHCI spec, in the definition of HCRST. It sounds like this host doesn't drive a USB reset down USB 3.0 ports at all on host controller reset? Oh, interesting, I hadn't seen that yet. So I guess the spec itself is fine if it were followed to the letter. I did some more tests about this on my Exynos machine: when I put a device to autosuspend (U3) and manually poke the xHC reset bit, I do see an automatic warm reset on the analyzer and the ports manage to retrain to U0. But after a system suspend/resume which calls xhci_reset() in the process, there is no reset on the wire. I also noticed that it doesn't drive a reset (even after manual poking) when there is no device connected on the other end of the analyzer. So this might be our problem: maybe these host controllers (Synopsys DesignWare) issue the spec-mandated warm reset only on ports where they think there is a device attached. But after a system suspend/resume (where the whole IP block on the SoC was powered down), the host controller cannot know that there is still a device with an active power session attached, and therefore doesn't drive the reset on its own. Even though this is a host controller bug, we still have to deal with it somehow. I guess we could move the code into xhci_plat_resume() and hide it behind a quirk to lessen the impact. But since reset_resume is not a common case for most host controllers, it's hard to say if this is DesignWare specific or a more widespread implementation mistake. I was going to suggest something along these lines too. This seems to be a bug in xHCI. Therefore the fix belongs in xhci-hcd, not in the hub driver. Alan Stern -- 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 2/2] usb: phy: Add keystone usb phy driver
-Original Message- From: Quadros, Roger Sent: Monday, December 09, 2013 10:09 PM To: Kwok, WingMan; linux-usb@vger.kernel.org Cc: linux-arm-ker...@lists.infradead.org; Shilimkar, Santosh; Balbi, Felipe; Greg Kroah-Hartman Subject: Re: [PATCH v3 2/2] usb: phy: Add keystone usb phy driver On 12/10/2013 03:47 AM, WingMan Kwok wrote: Add Keystone platform USB PHY driver support. Current main purpose of this driver is to enable the PHY reference clock gate on the Keystone SoC. Otherwise it is a nop PHY. Cc: Santosh Shilimkar santosh.shilim...@ti.com Cc: Felipe Balbi ba...@ti.com Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Acked-by: Santosh Shilimkar santosh.shilim...@ti.com Signed-off-by: WingMan Kwok w-kw...@ti.com --- drivers/usb/phy/Kconfig| 10 +++ drivers/usb/phy/Makefile |1 + drivers/usb/phy/phy-keystone.c | 142 3 files changed, 153 insertions(+) create mode 100644 drivers/usb/phy/phy-keystone.c diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index 08e2f39..c6792f43 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig @@ -40,6 +40,16 @@ config ISP1301_OMAP This driver can also be built as a module. If so, the module will be called isp1301_omap. +config KEYSTONE_USB_PHY + tristate Keystone USB PHY Driver + depends on ARCH_KEYSTONE + select USB_PHY NOP_USB_XCEIV selects USB_PHY so not necessary. Yes I have fixed it and updated patch which I'll post. config AM335X_PHY_USB needs to be fixed as well. Regards WingMan -- 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 0/2] Kesytone II USB host and PHY drivers
Resending the series with suggested minor updates from v3 [1]. Series adds USB host support for Keystone SOCs. Keystone SOCs uses dwc3 hardware IP implementation. On Keystone II platforms, we use no-op phy driver. Patchset are tested on Keystone II EVM with USB2.0 and USB3.0 flash drives along with dts changes. Cc: Felipe Balbi ba...@ti.com Cc: Santosh Shilimkar santosh.shilim...@ti.com WingMan Kwok (2): usb: dwc3: Add Keystone specific glue layer usb: phy: Add keystone usb phy driver drivers/usb/dwc3/Kconfig |7 ++ drivers/usb/dwc3/Makefile|1 + drivers/usb/dwc3/dwc3-keystone.c | 201 ++ drivers/usb/phy/Kconfig |9 ++ drivers/usb/phy/Makefile |1 + drivers/usb/phy/phy-keystone.c | 142 +++ 6 files changed, 361 insertions(+) create mode 100644 drivers/usb/dwc3/dwc3-keystone.c create mode 100644 drivers/usb/phy/phy-keystone.c [1] http://www.spinics.net/lists/linux-usb/msg99178.html -- 1.7.9.5 -- 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/2] usb: phy: Add keystone usb phy driver
Add Keystone platform USB PHY driver support. Current main purpose of this driver is to enable the PHY reference clock gate on the Keystone SoC. Otherwise it is a nop PHY. Cc: Santosh Shilimkar santosh.shilim...@ti.com Cc: Felipe Balbi ba...@ti.com Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Acked-by: Santosh Shilimkar santosh.shilim...@ti.com Signed-off-by: WingMan Kwok w-kw...@ti.com --- drivers/usb/phy/Kconfig|9 +++ drivers/usb/phy/Makefile |1 + drivers/usb/phy/phy-keystone.c | 142 3 files changed, 152 insertions(+) create mode 100644 drivers/usb/phy/phy-keystone.c diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index 08e2f39..3f2e829 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig @@ -40,6 +40,15 @@ config ISP1301_OMAP This driver can also be built as a module. If so, the module will be called isp1301_omap. +config KEYSTONE_USB_PHY + tristate Keystone USB PHY Driver + depends on ARCH_KEYSTONE + select NOP_USB_XCEIV + help + Enable this to support Keystone USB phy. This driver provides + interface to interact with USB 2.0 and USB 3.0 PHY that is part + of the Keystone SOC. + config MV_U3D_PHY bool Marvell USB 3.0 PHY controller Driver depends on CPU_MMP3 diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile index 022c1da..311b47b 100644 --- a/drivers/usb/phy/Makefile +++ b/drivers/usb/phy/Makefile @@ -30,3 +30,4 @@ obj-$(CONFIG_USB_RCAR_PHY)+= phy-rcar-usb.o obj-$(CONFIG_USB_RCAR_GEN2_PHY)+= phy-rcar-gen2-usb.o obj-$(CONFIG_USB_ULPI) += phy-ulpi.o obj-$(CONFIG_USB_ULPI_VIEWPORT)+= phy-ulpi-viewport.o +obj-$(CONFIG_KEYSTONE_USB_PHY) += phy-keystone.o diff --git a/drivers/usb/phy/phy-keystone.c b/drivers/usb/phy/phy-keystone.c new file mode 100644 index 000..f848ab6 --- /dev/null +++ b/drivers/usb/phy/phy-keystone.c @@ -0,0 +1,142 @@ +/* + * phy-keystone - USB PHY, talking to dwc3 controller in Keystone. + * + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Author: WingMan Kwok w-kw...@ti.com + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include linux/module.h +#include linux/platform_device.h +#include linux/usb/usb_phy_gen_xceiv.h +#include linux/io.h +#include linux/of.h + +#include phy-generic.h + +/* USB PHY control register offsets */ +#define USB_PHY_CTL_UTMI 0x +#define USB_PHY_CTL_PIPE 0x0004 +#define USB_PHY_CTL_PARAM_10x0008 +#define USB_PHY_CTL_PARAM_20x000c +#define USB_PHY_CTL_CLOCK 0x0010 +#define USB_PHY_CTL_PLL0x0014 + +#define PHY_REF_SSP_EN BIT(29) + +struct keystone_usbphy { + struct usb_phy_gen_xceivusb_phy_gen; + void __iomem*phy_ctrl; +}; + +static inline u32 keystone_usbphy_readl(void __iomem *base, u32 offset) +{ + return readl(base + offset); +} + +static inline void keystone_usbphy_writel(void __iomem *base, + u32 offset, u32 value) +{ + writel(value, base + offset); +} + +static int keystone_usbphy_init(struct usb_phy *phy) +{ + struct keystone_usbphy *k_phy = dev_get_drvdata(phy-dev); + u32 val; + + val = keystone_usbphy_readl(k_phy-phy_ctrl, USB_PHY_CTL_CLOCK); + keystone_usbphy_writel(k_phy-phy_ctrl, USB_PHY_CTL_CLOCK, + val | PHY_REF_SSP_EN); + return 0; +} + +static void keystone_usbphy_shutdown(struct usb_phy *phy) +{ + struct keystone_usbphy *k_phy = dev_get_drvdata(phy-dev); + u32 val; + + val = keystone_usbphy_readl(k_phy-phy_ctrl, USB_PHY_CTL_CLOCK); + keystone_usbphy_writel(k_phy-phy_ctrl, USB_PHY_CTL_CLOCK, + val = ~PHY_REF_SSP_EN); +} + +static int keystone_usbphy_probe(struct platform_device *pdev) +{ + struct device *dev = pdev-dev; + struct keystone_usbphy *k_phy; + struct resource *res; + int ret; + + k_phy = devm_kzalloc(dev, sizeof(*k_phy), GFP_KERNEL); + if (!k_phy) + return -ENOMEM; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(dev, missing usb phy resource\n); + return -EINVAL; + } + + k_phy-phy_ctrl =
Re: [PATCH v4 1/2] usb: dwc3: Add Keystone specific glue layer
Hi, On Thu, Dec 12, 2013 at 12:25:29PM -0500, WingMan Kwok wrote: +static int kdwc3_remove(struct platform_device *pdev) +{ + struct dwc3_keystone *kdwc = platform_get_drvdata(pdev); + + kdwc3_disable_irqs(kdwc); + clk_disable_unprepare(kdwc-clk); isn't this same clock feeding dwc3 core ? + device_for_each_child(pdev-dev, NULL, kdwc3_remove_core); if it is, you should disable the clock only *after* removing the core, provided core will access registers during remove. -- balbi signature.asc Description: Digital signature
Re: [PATCH v3 2/2] usb: phy: Add keystone usb phy driver
On Thu, Dec 12, 2013 at 11:20:54AM -0600, Kwok, WingMan wrote: -Original Message- From: Shilimkar, Santosh Sent: Tuesday, December 10, 2013 10:15 AM To: Balbi, Felipe Cc: Kwok, WingMan; linux-usb@vger.kernel.org; linux-arm- ker...@lists.infradead.org; Greg Kroah-Hartman Subject: Re: [PATCH v3 2/2] usb: phy: Add keystone usb phy driver On Monday 09 December 2013 09:54 PM, Balbi, Felipe wrote: Hi, On Mon, Dec 09, 2013 at 05:17:04PM -0500, WingMan Kwok wrote: +ret = usb_add_phy_dev(k_phy-usb_phy_gen.phy); +if (ret) +return ret; +k_phy-usb_phy_gen.phy.init = keystone_usbphy_init; +k_phy-usb_phy_gen.phy.shutdown = keystone_usbphy_shutdown; this *must* be initialized before adding the PHY to the subsystem. So these two lines must be moved before usb_add_phy_dev(). Make sense. Probably its good idea to repost the $subject patch with above as well as other delay related comment. Thanks. I have updated my patch accordingly. Please note that the same issue exists on drivers/usb/phy/phy-am335x.c also. If you want, I can send a fix for that. Will do, thanks for notifying me :-) -- balbi signature.asc Description: Digital signature
Re: [PATCH v3 1/2] usb: dwc3: Add Keystone specific glue layer
Hi, On Tue, Dec 10, 2013 at 10:11:36AM -0500, Santosh Shilimkar wrote: +static int kdwc3_remove(struct platform_device *pdev) +{ + struct dwc3_keystone *kdwc = platform_get_drvdata(pdev); + + kdwc3_disable_irqs(kdwc); + clk_disable_unprepare(kdwc-clk); I hope the clock isn't shared between core and wrapper, otherwise you could run into some troubles here. Can you confirm ? Yes. the clock isn't shared. Thanks for taking care of other parts. so clock for core is always running too ? -- balbi signature.asc Description: Digital signature
Re: [PATCH v3] usb: gadget: Add UDC driver for Aeroflex Gaisler GRUSBDC
Hi, On Wed, Dec 04, 2013 at 09:13:58AM +0100, Andreas Larsson wrote: +static void gr_finish_request(struct gr_ep *ep, struct gr_request *req, + int status) +{ + struct gr_udc *dev; + + list_del_init(req-queue); + + if (likely(req-req.status == -EINPROGRESS)) + req-req.status = status; + else + status = req-req.status; + + dev = ep-dev; + usb_gadget_unmap_request(dev-gadget, req-req, ep-is_in); + gr_free_dma_desc_chain(dev, req); + + if (ep-is_in) /* For OUT, actual gets updated bit by bit */ + req-req.actual = req-req.length; + + if (!status) { + if (ep-is_in) + gr_dbgprint_request(SENT, ep, req); + else + gr_dbgprint_request(RECV, ep, req); + } + + /* Prevent changes to ep-queue during callback */ + ep-callback = 1; + if (req == dev-ep0reqo !status) { + if (req-setup) + gr_ep0_setup(dev, req); + else + dev_err(dev-dev, + Unexpected non setup packet on ep0in\n); + } else if (req-req.complete) { + unsigned long flags; + + /* + * Complete should be called with interrupts disabled according + * to the contract of struct usb_request + */ + local_irq_save(flags); sorry but this driver isn't ready for inclusion. local_irq_save() is a pretty good hint that there's something wrong in the driver. Consider the fact that local_irq_save() will disable preemption even when CONFIG_PREEMPT_FULL is enabled and you have a bit a problem. Also, the way you're using thread IRQs is quite wrong. I can't let that pass and get merged upstream, sorry. -- balbi signature.asc Description: Digital signature
[PATCH] usb: gadget: f_fs: fix sparse warning
use NULL when returning NULL pointers, not 0. Signed-off-by: Felipe Balbi ba...@ti.com --- drivers/usb/gadget/f_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c index 12a64e1..306a2b5 100644 --- a/drivers/usb/gadget/f_fs.c +++ b/drivers/usb/gadget/f_fs.c @@ -1137,7 +1137,7 @@ static struct ffs_data *ffs_data_new(void) { struct ffs_data *ffs = kzalloc(sizeof *ffs, GFP_KERNEL); if (unlikely(!ffs)) - return 0; + return NULL; ENTER(); -- 1.8.4.GIT -- 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: gadget: f_fs: fix sparse warning
On Thu, Dec 12, 2013 at 12:16:31PM -0600, Felipe Balbi wrote: use NULL when returning NULL pointers, not 0. Signed-off-by: Felipe Balbi ba...@ti.com --- drivers/usb/gadget/f_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c index 12a64e1..306a2b5 100644 --- a/drivers/usb/gadget/f_fs.c +++ b/drivers/usb/gadget/f_fs.c @@ -1137,7 +1137,7 @@ static struct ffs_data *ffs_data_new(void) { struct ffs_data *ffs = kzalloc(sizeof *ffs, GFP_KERNEL); if (unlikely(!ffs)) - return 0; + return NULL; ENTER(); I'll send this on v3.14 merge window. -- balbi signature.asc Description: Digital signature
Re: [PATCH v2] USB: gadget: add maxpacket_limit field to struct usb_ep
On Thu, Dec 12, 2013 at 09:51:24AM +0100, Robert Baldyga wrote: This patch adds maxpacket_limit to struct usb_ep. This field contains maximum value of maxpacket supported by driver, and is set in driver probe. This value should be used by autoconfig() function, because value of field maxpacket is set to value from endpoint descriptor when endpoint becomes enabled. So when autoconfig() function will be called again for this endpoint, maxpacket value will contain wMaxPacketSize from descriptior instead of maximum packet size for this endpoint. For this reason this patch adds new field maxpacket_limit which contains value of maximum packet size (which defines maximum endpoint capabilities). This value is used in ep_matches() function used by autoconfig(). Value of maxpacket_limit should be set in UDC driver probe function, using usb_ep_set_maxpacket_limit() function, defined in gadget.h. This function set choosen value to both maxpacket_limit and maxpacket fields. This patch modifies UDC drivers by adding support for maxpacket_limit. Signed-off-by: Robert Baldyga r.bald...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com you're still missing drivers/usb/dwc3, drivers/usb/musb, drivers/usb/renesas_usbhs, drivers/usb/gadget/mv_u3d_core, drivers/usb/gadget/fsl_qe_udc (maybe), drivers/usb/gadget/net2272.c, drivers/usb/gadget/net2280.c and drivers/usb/chipidea -- balbi signature.asc Description: Digital signature
[PATCH] phy: core: properly handle failure of pm_runtime_get functions
In case pm_runtime_get*() fails, it still increments pm usage counter, so we *must* make sure to pm_runtime_put() even in those cases. This patch fixes that mistake the same way usbcore treats those possible failures. Signed-off-by: Felipe Balbi ba...@ti.com --- drivers/phy/phy-core.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 03cf8fb..5b61123 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -94,19 +94,27 @@ static struct phy_provider *of_phy_provider_lookup(struct device_node *node) int phy_pm_runtime_get(struct phy *phy) { + int ret; + if (!pm_runtime_enabled(phy-dev)) return -ENOTSUPP; - return pm_runtime_get(phy-dev); + ret = pm_runtime_get(phy-dev); + if (ret 0 ret != -EINPROGRESS) + pm_runtime_put_noidle(phy-dev); } EXPORT_SYMBOL_GPL(phy_pm_runtime_get); int phy_pm_runtime_get_sync(struct phy *phy) { + int ret; + if (!pm_runtime_enabled(phy-dev)) return -ENOTSUPP; - return pm_runtime_get_sync(phy-dev); + ret = pm_runtime_get_sync(phy-dev); + if (ret 0) + pm_runtime_put_sync(phy-dev); } EXPORT_SYMBOL_GPL(phy_pm_runtime_get_sync); -- 1.8.4.GIT -- 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: gadget: add maxpacket_limit field to struct usb_ep
From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb-ow...@vger.kernel.org] On Behalf Of Robert Baldyga Sent: Thursday, December 12, 2013 12:51 AM This patch adds maxpacket_limit to struct usb_ep. This field contains maximum value of maxpacket supported by driver, and is set in driver probe. This value should be used by autoconfig() function, because value of field maxpacket is set to value from endpoint descriptor when endpoint becomes enabled. So when autoconfig() function will be called again for this endpoint, maxpacket value will contain wMaxPacketSize from descriptior instead of maximum packet size for this endpoint. Can you describe what the exact problem is that this patch is trying to solve? Under what circumstances does the problem show up? And perhaps a pointer to any previous email thread where this was discussed? Thanks. -- Paul -- 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 1/2] usb: dwc3: Add Keystone specific glue layer
On Thu, Dec 12, 2013 at 02:36:01PM -0500, Santosh Shilimkar wrote: On Thursday 12 December 2013 12:48 PM, Felipe Balbi wrote: Hi, On Tue, Dec 10, 2013 at 10:11:36AM -0500, Santosh Shilimkar wrote: +static int kdwc3_remove(struct platform_device *pdev) +{ +struct dwc3_keystone *kdwc = platform_get_drvdata(pdev); + +kdwc3_disable_irqs(kdwc); +clk_disable_unprepare(kdwc-clk); I hope the clock isn't shared between core and wrapper, otherwise you could run into some troubles here. Can you confirm ? Yes. the clock isn't shared. Thanks for taking care of other parts. so clock for core is always running too ? I take that back. The clock is actually common so we should disable it after removing the kdwc3_remove_core() as you suggested. You won't see issue since the kdwc3_remove_core() not doing any register access but moving the clock disable after the core remove is right thing to do. the problem is not kdwc3_remove_core() accessing registers, but dwc3_remove() _does_ access registers during remove. If you just mopdrobe -r dwc3-keystone without removing dwc3.ko first, then kdwc3_remove_core() will cause dwc3.ko to be removed (because of platform_driver_unregister()) and, since clocks have already been disabled, then we'd die :-) cheers -- balbi signature.asc Description: Digital signature
[PATCH v5 1/2] usb: dwc3: Add Keystone specific glue layer
Add Keystone platform specific glue layer to support USB3 Host mode. Cc: Santosh Shilimkar santosh.shilim...@ti.com Cc: Felipe Balbi ba...@ti.com Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Acked-by: Santosh Shilimkar santosh.shilim...@ti.com Signed-off-by: WingMan Kwok w-kw...@ti.com --- v4-v5: Moved clk_disable after removing core. drivers/usb/dwc3/Kconfig |7 ++ drivers/usb/dwc3/Makefile|1 + drivers/usb/dwc3/dwc3-keystone.c | 201 ++ 3 files changed, 209 insertions(+) create mode 100644 drivers/usb/dwc3/dwc3-keystone.c diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig index 70fc430..e2c730f 100644 --- a/drivers/usb/dwc3/Kconfig +++ b/drivers/usb/dwc3/Kconfig @@ -70,6 +70,13 @@ config USB_DWC3_PCI One such PCIe-based platform is Synopsys' PCIe HAPS model of this IP. +config USB_DWC3_KEYSTONE + tristate Texas Instruments Keystone2 Platforms + default USB_DWC3 + help + Support of USB2/3 functionality in TI Keystone2 platforms. + Say 'Y' or 'M' here if you have one such device + comment Debugging features config USB_DWC3_DEBUG diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile index dd17601..10ac3e7 100644 --- a/drivers/usb/dwc3/Makefile +++ b/drivers/usb/dwc3/Makefile @@ -32,3 +32,4 @@ endif obj-$(CONFIG_USB_DWC3_OMAP)+= dwc3-omap.o obj-$(CONFIG_USB_DWC3_EXYNOS) += dwc3-exynos.o obj-$(CONFIG_USB_DWC3_PCI) += dwc3-pci.o +obj-$(CONFIG_USB_DWC3_KEYSTONE)+= dwc3-keystone.o diff --git a/drivers/usb/dwc3/dwc3-keystone.c b/drivers/usb/dwc3/dwc3-keystone.c new file mode 100644 index 000..e3e34eb --- /dev/null +++ b/drivers/usb/dwc3/dwc3-keystone.c @@ -0,0 +1,201 @@ +/** + * dwc3-keystone.c - Keystone Specific Glue layer + * + * Copyright (C) 2010-2013 Texas Instruments Incorporated - http://www.ti.com + * + * Author: WingMan Kwok w-kw...@ti.com + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 of + * the License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include linux/clk.h +#include linux/module.h +#include linux/kernel.h +#include linux/interrupt.h +#include linux/platform_device.h +#include linux/dma-mapping.h +#include linux/io.h +#include linux/of_platform.h + +/* USBSS register offsets */ +#define USBSS_REVISION 0x +#define USBSS_SYSCONFIG0x0010 +#define USBSS_IRQ_EOI 0x0018 +#define USBSS_IRQSTATUS_RAW_0 0x0020 +#define USBSS_IRQSTATUS_0 0x0024 +#define USBSS_IRQENABLE_SET_0 0x0028 +#define USBSS_IRQENABLE_CLR_0 0x002c + +/* IRQ register bits */ +#define USBSS_IRQ_EOI_LINE(n) BIT(n) +#define USBSS_IRQ_EVENT_ST BIT(0) +#define USBSS_IRQ_COREIRQ_EN BIT(0) +#define USBSS_IRQ_COREIRQ_CLR BIT(0) + +static u64 kdwc3_dma_mask; + +struct dwc3_keystone { + struct device *dev; + struct clk *clk; + void __iomem*usbss; +}; + +static inline u32 kdwc3_readl(void __iomem *base, u32 offset) +{ + return readl(base + offset); +} + +static inline void kdwc3_writel(void __iomem *base, u32 offset, u32 value) +{ + writel(value, base + offset); +} + +static void kdwc3_enable_irqs(struct dwc3_keystone *kdwc) +{ + u32 val; + + val = kdwc3_readl(kdwc-usbss, USBSS_IRQENABLE_SET_0); + val |= USBSS_IRQ_COREIRQ_EN; + kdwc3_writel(kdwc-usbss, USBSS_IRQENABLE_SET_0, val); +} + +static void kdwc3_disable_irqs(struct dwc3_keystone *kdwc) +{ + u32 val; + + val = kdwc3_readl(kdwc-usbss, USBSS_IRQENABLE_SET_0); + val = ~USBSS_IRQ_COREIRQ_EN; + kdwc3_writel(kdwc-usbss, USBSS_IRQENABLE_SET_0, val); +} + +static irqreturn_t dwc3_keystone_interrupt(int irq, void *_kdwc) +{ + struct dwc3_keystone*kdwc = _kdwc; + + kdwc3_writel(kdwc-usbss, USBSS_IRQENABLE_CLR_0, USBSS_IRQ_COREIRQ_CLR); + kdwc3_writel(kdwc-usbss, USBSS_IRQSTATUS_0, USBSS_IRQ_EVENT_ST); + kdwc3_writel(kdwc-usbss, USBSS_IRQENABLE_SET_0, USBSS_IRQ_COREIRQ_EN); + kdwc3_writel(kdwc-usbss, USBSS_IRQ_EOI, USBSS_IRQ_EOI_LINE(0)); + + return IRQ_HANDLED; +} + +static int kdwc3_probe(struct platform_device *pdev) +{ + struct device *dev = pdev-dev; + struct device_node *node = pdev-dev.of_node; + struct dwc3_keystone*kdwc; + struct resource *res; + int error, irq; + + kdwc = devm_kzalloc(dev, sizeof(*kdwc), GFP_KERNEL); + if (!kdwc) + return -ENOMEM; + + platform_set_drvdata(pdev, kdwc); +
Re: [PATCH v3 1/2] usb: dwc3: Add Keystone specific glue layer
On Thursday 12 December 2013 02:41 PM, Felipe Balbi wrote: On Thu, Dec 12, 2013 at 02:36:01PM -0500, Santosh Shilimkar wrote: On Thursday 12 December 2013 12:48 PM, Felipe Balbi wrote: Hi, On Tue, Dec 10, 2013 at 10:11:36AM -0500, Santosh Shilimkar wrote: +static int kdwc3_remove(struct platform_device *pdev) +{ +struct dwc3_keystone *kdwc = platform_get_drvdata(pdev); + +kdwc3_disable_irqs(kdwc); +clk_disable_unprepare(kdwc-clk); I hope the clock isn't shared between core and wrapper, otherwise you could run into some troubles here. Can you confirm ? Yes. the clock isn't shared. Thanks for taking care of other parts. so clock for core is always running too ? I take that back. The clock is actually common so we should disable it after removing the kdwc3_remove_core() as you suggested. You won't see issue since the kdwc3_remove_core() not doing any register access but moving the clock disable after the core remove is right thing to do. the problem is not kdwc3_remove_core() accessing registers, but dwc3_remove() _does_ access registers during remove. If you just mopdrobe -r dwc3-keystone without removing dwc3.ko first, then kdwc3_remove_core() will cause dwc3.ko to be removed (because of platform_driver_unregister()) and, since clocks have already been disabled, then we'd die :-) Oh yes, you are right. I see Wingman already posted the updated patch. Regards, Santosh -- 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 v5 1/2] usb: dwc3: Add Keystone specific glue layer
Hi, On Thu, Dec 12, 2013 at 02:49:22PM -0500, WingMan Kwok wrote: +static int kdwc3_remove(struct platform_device *pdev) +{ + struct dwc3_keystone *kdwc = platform_get_drvdata(pdev); + + kdwc3_disable_irqs(kdwc); + device_for_each_child(pdev-dev, NULL, kdwc3_remove_core); + platform_set_drvdata(pdev, NULL); + clk_disable_unprepare(kdwc-clk); + return 0; I had already fixed it in my branch, thaks anyway :-) -- balbi signature.asc Description: Digital signature
Re: [PATCH] usb: gadget: f_fs: fix sparse warning
On Thu, Dec 12 2013, Felipe Balbi wrote: use NULL when returning NULL pointers, not 0. Signed-off-by: Felipe Balbi ba...@ti.com Acked-by: Michal Nazarewicz min...@mina86.com --- drivers/usb/gadget/f_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c index 12a64e1..306a2b5 100644 --- a/drivers/usb/gadget/f_fs.c +++ b/drivers/usb/gadget/f_fs.c @@ -1137,7 +1137,7 @@ static struct ffs_data *ffs_data_new(void) { struct ffs_data *ffs = kzalloc(sizeof *ffs, GFP_KERNEL); if (unlikely(!ffs)) - return 0; + return NULL; ENTER(); -- 1.8.4.GIT -- Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michał “mina86” Nazarewicz(o o) ooo +--m...@google.com--xmpp:min...@jabber.org--ooO--(_)--Ooo-- signature.asc Description: PGP signature
Re: WG: [PATCH] usb: musb: omap2430: fix occasional musb breakage on boot
Hi Grazvydas, Von: Grazvydas Ignotas [mailto:nota...@gmail.com] Gesendet: Donnerstag, 12. Dezember 2013 01:21 An: linux-usb@vger.kernel.org Cc: Felipe Balbi; linux-o...@vger.kernel.org; Naumann Andreas; Grazvydas Ignotas; sta...@vger.kernel.org Betreff: [PATCH] usb: musb: omap2430: fix occasional musb breakage on boot This is a hard to reproduce problem which leads to non-functional USB-OTG port in 0.1%-1% of all boots. Tracked it down to commit e25bec160158abe86c omap2+: save and restore OTG_INTERFSEL, which introduces save/restore of OTG_INTERFSEL over suspend. Since the resume function is also called early in driver init, it uses a non-initialized value (which is 0 and a non-supported setting in DM37xx for INTERFSEL). Shortly after the correct value is set. Apparently this works most time, but not always. Fix it by not writing the value on runtime resume if it is 0 (0 should never be saved in the context as it's invalid value, so we use it as an indicator that context hasn't been saved yet). This issue was originally found by Andreas Naumann: http://marc.info/?l=linux-usbm=138562574719654w=2 Reported-and-bisected-by: Andreas Naumann anaum...@ultratronik.de Signed-off-by: Grazvydas Ignotas nota...@gmail.com Cc: sta...@vger.kernel.org --- This is a regression from 3.2, so should go to -rc and stable, IMO. It's really annoying issue if you want to have a stable OTG behavior, I've burned quite a lot of time on it myself over a year ago and gave up eventually. Good thing Andreas finally found it, many thanks to him! drivers/usb/musb/omap2430.c |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 2a408cd..737b3da 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -672,7 +672,8 @@ static int omap2430_runtime_resume(struct device *dev) if (musb) { omap2430_low_level_init(musb); - musb_writel(musb-mregs, OTG_INTERFSEL, + if (musb-context.otg_interfsel != 0) + musb_writel(musb-mregs, OTG_INTERFSEL, musb-context.otg_interfsel); phy_power_on(musb-phy); } Oh, easy way out. I like it but I've also been thinking about your comment on my original post, which was that initializing otg_interfsel to the PHYSEL bits only might be dangerous because we cant be sure that there are other bits in the register. However, isnt assuming that 0 is invalid on all OMAPs just as dangerous? After thinking about my patch again, I would propose to change otg_interfsel into otg_physel and read-modify-write only those bits in resume() as you suggested in your first answer. That way I could discard the problematic first read in probe() while leaving other bits untouched. If you agree I post a patch for this tomorrow. cheers, Andreas -- 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 5/7] usb: dwc3: omap: fix order of pm_runtime vs child removal
pm_runtime_put_sync() will kill dwc3's clocks and, since dwc3 core accesses registers during removal, we must make sure to unregister core before disabling clocks and pm_runtime. Signed-off-by: Felipe Balbi ba...@ti.com --- drivers/usb/dwc3/dwc3-omap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index 076bb28..a9090a1 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c @@ -580,9 +580,9 @@ static int dwc3_omap_remove(struct platform_device *pdev) if (omap-extcon_id_dev.edev) extcon_unregister_interest(omap-extcon_id_dev); dwc3_omap_disable_irqs(omap); + device_for_each_child(pdev-dev, NULL, dwc3_omap_remove_core); pm_runtime_put_sync(pdev-dev); pm_runtime_disable(pdev-dev); - device_for_each_child(pdev-dev, NULL, dwc3_omap_remove_core); return 0; } -- 1.8.4.GIT -- 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 3/7] usb: dwc3: pci: add pm_runtime support
teach the PCI glue about pm_runtime so that it's easier to teach dwc3 core about it later. No functional changes otherwise. Signed-off-by: Felipe Balbi ba...@ti.com --- drivers/usb/dwc3/dwc3-pci.c | 66 ++--- 1 file changed, 51 insertions(+), 15 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c index 665686e..78cd0b0 100644 --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c @@ -109,18 +109,17 @@ static int dwc3_pci_probe(struct pci_dev *pci, glue-dev = dev; - ret = pci_enable_device(pci); + pm_runtime_enable(dev); + ret = pm_runtime_get_sync(dev); if (ret) { dev_err(dev, failed to enable pci device\n); return -ENODEV; } - pci_set_master(pci); - ret = dwc3_pci_register_phys(glue); if (ret) { dev_err(dev, couldn't register PHYs\n); - return ret; + goto err1; } dwc3 = platform_device_alloc(dwc3, PLATFORM_DEVID_AUTO); @@ -167,7 +166,8 @@ static int dwc3_pci_probe(struct pci_dev *pci, err3: platform_device_put(dwc3); err1: - pci_disable_device(pci); + pm_runtime_put_sync(dev); + pm_runtime_disable(dev); return ret; } @@ -175,11 +175,13 @@ err1: static void dwc3_pci_remove(struct pci_dev *pci) { struct dwc3_pci *glue = pci_get_drvdata(pci); + struct device *dev = pci-dev; platform_device_unregister(glue-dwc3); platform_device_unregister(glue-usb2_phy); platform_device_unregister(glue-usb3_phy); - pci_disable_device(pci); + pm_runtime_put_sync(dev); + pm_runtime_disable(dev); } static const struct pci_device_id dwc3_pci_id_table[] = { @@ -193,24 +195,20 @@ static const struct pci_device_id dwc3_pci_id_table[] = { }; MODULE_DEVICE_TABLE(pci, dwc3_pci_id_table); -#ifdef CONFIG_PM_SLEEP -static int dwc3_pci_suspend(struct device *dev) +static int __dwc3_pci_suspend(struct pci_dev *pci) { - struct pci_dev *pci = to_pci_dev(dev); - pci_disable_device(pci); return 0; } -static int dwc3_pci_resume(struct device *dev) +static int __dwc3_pci_resume(struct pci_dev *pci) { - struct pci_dev *pci = to_pci_dev(dev); - int ret; + int ret; ret = pci_enable_device(pci); if (ret) { - dev_err(dev, can't re-enable device -- %d\n, ret); + dev_err(pci-dev, can't re-enable device -- %d\n, ret); return ret; } @@ -218,10 +216,48 @@ static int dwc3_pci_resume(struct device *dev) return 0; } -#endif /* CONFIG_PM_SLEEP */ + +static int dwc3_pci_suspend(struct device *dev) +{ + struct pci_dev *pci = to_pci_dev(dev); + + return __dwc3_pci_suspend(pci); +} + +static int dwc3_pci_resume(struct device *dev) +{ + struct pci_dev *pci = to_pci_dev(dev); + int ret; + + ret = __dwc3_pci_resume(pci); + if (ret) + return ret; + + pm_runtime_disable(dev); + pm_runtime_set_active(dev); + pm_runtime_disable(dev); + + return 0; +} + +static int dwc3_pci_runtime_suspend(struct device *dev) +{ + struct pci_dev *pci = to_pci_dev(dev); + + return __dwc3_pci_suspend(pci); +} + +static int dwc3_pci_runtime_resume(struct device *dev) +{ + struct pci_dev *pci = to_pci_dev(dev); + + return __dwc3_pci_resume(pci); +} static const struct dev_pm_ops dwc3_pci_dev_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(dwc3_pci_suspend, dwc3_pci_resume) + SET_RUNTIME_PM_OPS(dwc3_pci_runtime_suspend, dwc3_pci_runtime_resume, + NULL) }; static struct pci_driver dwc3_pci_driver = { -- 1.8.4.GIT -- 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 6/7] usb: dwc3: exynos: remove DEV_PM_OPS hackery
it's best to just remove all ifdefs and always define our dev_pm_ops structure. Signed-off-by: Felipe Balbi ba...@ti.com --- drivers/usb/dwc3/dwc3-exynos.c | 8 +--- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c index 8b20c70..6ccfc64 100644 --- a/drivers/usb/dwc3/dwc3-exynos.c +++ b/drivers/usb/dwc3/dwc3-exynos.c @@ -184,7 +184,6 @@ static const struct of_device_id exynos_dwc3_match[] = { MODULE_DEVICE_TABLE(of, exynos_dwc3_match); #endif -#ifdef CONFIG_PM_SLEEP static int dwc3_exynos_suspend(struct device *dev) { struct dwc3_exynos *exynos = dev_get_drvdata(dev); @@ -212,18 +211,13 @@ static const struct dev_pm_ops dwc3_exynos_dev_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(dwc3_exynos_suspend, dwc3_exynos_resume) }; -#define DEV_PM_OPS (dwc3_exynos_dev_pm_ops) -#else -#define DEV_PM_OPS NULL -#endif /* CONFIG_PM_SLEEP */ - static struct platform_driver dwc3_exynos_driver = { .probe = dwc3_exynos_probe, .remove = dwc3_exynos_remove, .driver = { .name = exynos-dwc3, .of_match_table = of_match_ptr(exynos_dwc3_match), - .pm = DEV_PM_OPS, + .pm = dwc3_exynos_dev_pm_ops, }, }; -- 1.8.4.GIT -- 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 4/7] usb: dwc3: omap: fix pm_runtime usage
even if pm_runtime_get*() fails, it still increments pm usage counter, so we must pm_runtime_put*() in that case too. Fix that observation in dwc3-omap.c. Signed-off-by: Felipe Balbi ba...@ti.com --- drivers/usb/dwc3/dwc3-omap.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index aea305d..076bb28 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c @@ -451,7 +451,7 @@ static int dwc3_omap_probe(struct platform_device *pdev) ret = pm_runtime_get_sync(dev); if (ret 0) { dev_err(dev, get_sync failed with err %d\n, ret); - goto err0; + goto err1; } reg = dwc3_omap_readl(omap-base, USBOTGSS_REVISION); @@ -566,8 +566,6 @@ err2: err1: pm_runtime_put_sync(dev); - -err0: pm_runtime_disable(dev); return ret; -- 1.8.4.GIT -- 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 7/7] usb: dwc3: exynos: add pm_runtime support
teach Exynos glue about pm_runtime so that it's easier to teach dwc3 core about it later. No functional changes otherwise. Signed-off-by: Felipe Balbi ba...@ti.com --- drivers/usb/dwc3/dwc3-exynos.c | 65 -- 1 file changed, 56 insertions(+), 9 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c index 6ccfc64..c93919a 100644 --- a/drivers/usb/dwc3/dwc3-exynos.c +++ b/drivers/usb/dwc3/dwc3-exynos.c @@ -141,24 +141,40 @@ static int dwc3_exynos_probe(struct platform_device *pdev) exynos-dev = dev; exynos-clk = clk; - clk_prepare_enable(exynos-clk); + ret = clk_prepare(exynos-clk); + if (ret) { + dev_err(dev, failed to prepare clock\n); + goto err2; + } + + pm_runtime_enable(dev); + ret = pm_runtime_get_sync(dev); + if (ret) { + dev_err(dev, failed to enable dwc3 device\n); + goto err3; + } if (node) { ret = of_platform_populate(node, NULL, NULL, dev); if (ret) { dev_err(dev, failed to add dwc3 core\n); - goto err2; + goto err3; } } else { dev_err(dev, no device node, failed to add dwc3 core\n); ret = -ENODEV; - goto err2; + goto err3; } return 0; +err3: + pm_runtime_put_sync(dev); + pm_runtime_disable(dev); + err2: - clk_disable_unprepare(clk); + clk_unprepare(clk); + err1: return ret; } @@ -171,7 +187,9 @@ static int dwc3_exynos_remove(struct platform_device *pdev) platform_device_unregister(exynos-usb2_phy); platform_device_unregister(exynos-usb3_phy); - clk_disable_unprepare(exynos-clk); + pm_runtime_put_sync(exynos-dev); + pm_runtime_disable(exynos-dev); + clk_unprepare(exynos-clk); return 0; } @@ -184,20 +202,33 @@ static const struct of_device_id exynos_dwc3_match[] = { MODULE_DEVICE_TABLE(of, exynos_dwc3_match); #endif -static int dwc3_exynos_suspend(struct device *dev) +static int __dwc3_exynos_suspend(struct dwc3_exynos *exynos) { - struct dwc3_exynos *exynos = dev_get_drvdata(dev); - clk_disable(exynos-clk); return 0; } +static int __dwc3_exynos_resume(struct dwc3_exynos *exynos) +{ + return clk_enable(exynos-clk); +} + +static int dwc3_exynos_suspend(struct device *dev) +{ + struct dwc3_exynos *exynos = dev_get_drvdata(dev); + + return __dwc3_exynos_suspend(exynos); +} + static int dwc3_exynos_resume(struct device *dev) { struct dwc3_exynos *exynos = dev_get_drvdata(dev); + int ret; - clk_enable(exynos-clk); + ret = __dwc3_exynos_resume(exynos); + if (ret) + return ret; /* runtime set active to reflect active state. */ pm_runtime_disable(dev); @@ -207,8 +238,24 @@ static int dwc3_exynos_resume(struct device *dev) return 0; } +static int dwc3_exynos_runtime_suspend(struct device *dev) +{ + struct dwc3_exynos *exynos = dev_get_drvdata(dev); + + return __dwc3_exynos_suspend(exynos); +} + +static int dwc3_exynos_runtime_resume(struct device *dev) +{ + struct dwc3_exynos *exynos = dev_get_drvdata(dev); + + return __dwc3_exynos_resume(exynos); +} + static const struct dev_pm_ops dwc3_exynos_dev_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(dwc3_exynos_suspend, dwc3_exynos_resume) + SET_RUNTIME_PM_OPS(dwc3_exynos_runtime_suspend, + dwc3_exynos_runtime_resume, NULL) }; static struct platform_driver dwc3_exynos_driver = { -- 1.8.4.GIT -- 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/7] usb: dwc3: omap: add basic pm_runtime support
If we want to suspend/runtime in runtime, we can do so, in OMAP's case at least, with the same implementation we use for system pm. This patch adds basic pm_runtime support with that in mind. Signed-off-by: Felipe Balbi ba...@ti.com --- drivers/usb/dwc3/dwc3-omap.c | 39 +++ 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index b269dbd..aea305d 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c @@ -617,20 +617,35 @@ static void dwc3_omap_complete(struct device *dev) dwc3_omap_enable_irqs(omap); } -static int dwc3_omap_suspend(struct device *dev) +static int __dwc3_omap_suspend(struct dwc3_omap *omap) { - struct dwc3_omap*omap = dev_get_drvdata(dev); - omap-utmi_otg_status = dwc3_omap_read_utmi_status(omap); return 0; } +static int __dwc3_omap_resume(struct dwc3_omap *omap) +{ + dwc3_omap_write_utmi_status(omap, omap-utmi_otg_status); + + return 0; +} + +static int dwc3_omap_suspend(struct device *dev) +{ + struct dwc3_omap*omap = dev_get_drvdata(dev); + + return __dwc3_omap_suspend(omap); +} + static int dwc3_omap_resume(struct device *dev) { struct dwc3_omap*omap = dev_get_drvdata(dev); + int ret; - dwc3_omap_write_utmi_status(omap, omap-utmi_otg_status); + ret = __dwc3_omap_resume(omap); + if (ret) + return ret; pm_runtime_disable(dev); pm_runtime_set_active(dev); @@ -639,11 +654,27 @@ static int dwc3_omap_resume(struct device *dev) return 0; } +static int dwc3_omap_runtime_suspend(struct device *dev) +{ + struct dwc3_omap*omap = dev_get_drvdata(dev); + + return __dwc3_omap_suspend(omap); +} + +static int dwc3_omap_runtime_resume(struct device *dev) +{ + struct dwc3_omap*omap = dev_get_drvdata(dev); + + return __dwc3_omap_resume(omap); +} + static const struct dev_pm_ops dwc3_omap_dev_pm_ops = { .prepare= dwc3_omap_prepare, .complete = dwc3_omap_complete, SET_SYSTEM_SLEEP_PM_OPS(dwc3_omap_suspend, dwc3_omap_resume) + SET_RUNTIME_PM_OPS(dwc3_omap_runtime_suspend, dwc3_omap_runtime_resume, + NULL) }; #define DEV_PM_OPS (dwc3_omap_dev_pm_ops) -- 1.8.4.GIT -- 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 0/7] usb: dwc3: pm_runtime implementation
hi all, these patches add pm_runtime support for all glue layers. I plan to add pm_runtime support for dwc3 after these patches are merged upstream. Please test. Felipe Balbi (7): usb: dwc3: keystone: add basic PM support usb: dwc3: omap: add basic pm_runtime support usb: dwc3: pci: add pm_runtime support usb: dwc3: omap: fix pm_runtime usage usb: dwc3: omap: fix order of pm_runtime vs child removal usb: dwc3: exynos: remove DEV_PM_OPS hackery usb: dwc3: exynos: add pm_runtime support drivers/usb/dwc3/dwc3-exynos.c | 73 +++--- drivers/usb/dwc3/dwc3-keystone.c | 97 ++-- drivers/usb/dwc3/dwc3-omap.c | 45 +++ drivers/usb/dwc3/dwc3-pci.c | 66 --- 4 files changed, 239 insertions(+), 42 deletions(-) -- 1.8.4.GIT -- 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/7] usb: dwc3: keystone: add basic PM support
A bare-minimum PM implementation which will server as building block for more complex PM implementation in the future. At the least will not leave clocks on unnecessarily when e.g. a user write mem to /sys/power/state. Signed-off-by: Felipe Balbi ba...@ti.com --- drivers/usb/dwc3/dwc3-keystone.c | 97 ++-- 1 file changed, 94 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-keystone.c b/drivers/usb/dwc3/dwc3-keystone.c index 1fad161..361437f 100644 --- a/drivers/usb/dwc3/dwc3-keystone.c +++ b/drivers/usb/dwc3/dwc3-keystone.c @@ -21,6 +21,7 @@ #include linux/interrupt.h #include linux/platform_device.h #include linux/dma-mapping.h +#include linux/pm_runtime.h #include linux/io.h #include linux/of_platform.h @@ -118,13 +119,23 @@ static int kdwc3_probe(struct platform_device *pdev) kdwc-clk = devm_clk_get(kdwc-dev, usb); - error = clk_prepare_enable(kdwc-clk); + error = clk_prepare(kdwc-clk); if (error 0) { dev_dbg(kdwc-dev, unable to enable usb clock, err %d\n, error); return error; } + pm_runtime_enable(dev); + + error = pm_runtime_get_sync(dev); + if (error 0) { + dev_dbg(dev, unable to pm_runtime_get_sync(), err %d\n, + error); + pm_runtime_put_sync(dev); + goto err_runtime_get; + } + irq = platform_get_irq(pdev, 0); if (irq 0) { dev_err(pdev-dev, missing irq\n); @@ -151,8 +162,13 @@ static int kdwc3_probe(struct platform_device *pdev) err_core: kdwc3_disable_irqs(kdwc); + err_irq: - clk_disable_unprepare(kdwc-clk); + pm_runtime_put_sync(dev); + +err_runtime_get: + pm_runtime_disable(dev); + clk_unprepare(kdwc-clk); return error; } @@ -172,7 +188,9 @@ static int kdwc3_remove(struct platform_device *pdev) kdwc3_disable_irqs(kdwc); device_for_each_child(pdev-dev, NULL, kdwc3_remove_core); - clk_disable_unprepare(kdwc-clk); + pm_runtime_put_sync(pdev-dev); + pm_runtime_disable(pdev-dev); + clk_unprepare(kdwc-clk); platform_set_drvdata(pdev, NULL); return 0; @@ -184,6 +202,79 @@ static const struct of_device_id kdwc3_of_match[] = { }; MODULE_DEVICE_TABLE(of, kdwc3_of_match); +static int __kdwc3_suspend(struct dwc3_keystone *kdwc) +{ + clk_disable(kdwc-clk); + + return 0; +} + +static int __kdwc3_resume(struct dwc3_keystone *kdwc) +{ + return clk_enable(kdwc-clk); +} + +static int kdwc3_prepare(struct device *dev) +{ + struct dwc3_keystone*kdwc = dev_get_drvdata(dev); + + kdwc3_disable_irqs(kdwc); + + return 0; +} + +static void kdwc3_complete(struct device *dev) +{ + struct dwc3_keystone*kdwc = dev_get_drvdata(dev); + + kdwc3_enable_irqs(kdwc); +} + +static int kdwc3_suspend(struct device *dev) +{ + struct dwc3_keystone*kdwc = dev_get_drvdata(dev); + + return __kdwc3_suspend(kdwc); +} + +static int kdwc3_resume(struct device *dev) +{ + struct dwc3_keystone*kdwc = dev_get_drvdata(dev); + int ret; + + ret = __kdwc3_resume(kdwc); + if (ret) + return ret; + + pm_runtime_disable(dev); + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + + return 0; +} + +static int kdwc3_runtime_suspend(struct device *dev) +{ + struct dwc3_keystone *kdwc = dev_get_drvdata(dev); + + return __kdwc3_suspend(kdwc); +} + +static int kdwc3_runtime_resume(struct device *dev) +{ + struct dwc3_keystone *kdwc = dev_get_drvdata(dev); + + return __kdwc3_resume(kdwc); +} + +static const struct dev_pm_ops kdwc3_dev_pm_ops = { + .prepare= kdwc3_prepare, + .complete = kdwc3_complete, + + SET_SYSTEM_SLEEP_PM_OPS(kdwc3_suspend, kdwc3_resume) + SET_RUNTIME_PM_OPS(kdwc3_runtime_suspend, kdwc3_runtime_resume, NULL) +}; + static struct platform_driver kdwc3_driver = { .probe = kdwc3_probe, .remove = kdwc3_remove, -- 1.8.4.GIT -- 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/7] usb: dwc3: keystone: add basic PM support
On Thu, Dec 12, 2013 at 03:38:39PM -0600, Felipe Balbi wrote: A bare-minimum PM implementation which will server as building block for more complex PM implementation in the future. At the least will not leave clocks on unnecessarily when e.g. a user write mem to /sys/power/state. Signed-off-by: Felipe Balbi ba...@ti.com --- drivers/usb/dwc3/dwc3-keystone.c | 97 ++-- 1 file changed, 94 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-keystone.c b/drivers/usb/dwc3/dwc3-keystone.c index 1fad161..361437f 100644 --- a/drivers/usb/dwc3/dwc3-keystone.c +++ b/drivers/usb/dwc3/dwc3-keystone.c @@ -21,6 +21,7 @@ #include linux/interrupt.h #include linux/platform_device.h #include linux/dma-mapping.h +#include linux/pm_runtime.h #include linux/io.h #include linux/of_platform.h @@ -118,13 +119,23 @@ static int kdwc3_probe(struct platform_device *pdev) kdwc-clk = devm_clk_get(kdwc-dev, usb); - error = clk_prepare_enable(kdwc-clk); + error = clk_prepare(kdwc-clk); if (error 0) { dev_dbg(kdwc-dev, unable to enable usb clock, err %d\n, error); return error; } + pm_runtime_enable(dev); + + error = pm_runtime_get_sync(dev); + if (error 0) { + dev_dbg(dev, unable to pm_runtime_get_sync(), err %d\n, + error); + pm_runtime_put_sync(dev); I can move this pm_runtime_sync() to error path, will refresh this patch. -- balbi signature.asc Description: Digital signature
[PATCH v2 1/7] usb: dwc3: keystone: add basic PM support
A bare-minimum PM implementation which will server as building block for more complex PM implementation in the future. At the least will not leave clocks on unnecessarily when e.g. a user write mem to /sys/power/state. Signed-off-by: Felipe Balbi ba...@ti.com --- improve error path a little bit. drivers/usb/dwc3/dwc3-keystone.c | 94 ++-- 1 file changed, 91 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-keystone.c b/drivers/usb/dwc3/dwc3-keystone.c index 1fad161..3b3761c 100644 --- a/drivers/usb/dwc3/dwc3-keystone.c +++ b/drivers/usb/dwc3/dwc3-keystone.c @@ -21,6 +21,7 @@ #include linux/interrupt.h #include linux/platform_device.h #include linux/dma-mapping.h +#include linux/pm_runtime.h #include linux/io.h #include linux/of_platform.h @@ -118,13 +119,22 @@ static int kdwc3_probe(struct platform_device *pdev) kdwc-clk = devm_clk_get(kdwc-dev, usb); - error = clk_prepare_enable(kdwc-clk); + error = clk_prepare(kdwc-clk); if (error 0) { dev_dbg(kdwc-dev, unable to enable usb clock, err %d\n, error); return error; } + pm_runtime_enable(dev); + + error = pm_runtime_get_sync(dev); + if (error 0) { + dev_dbg(dev, unable to pm_runtime_get_sync(), err %d\n, + error); + goto err_irq; + } + irq = platform_get_irq(pdev, 0); if (irq 0) { dev_err(pdev-dev, missing irq\n); @@ -151,8 +161,11 @@ static int kdwc3_probe(struct platform_device *pdev) err_core: kdwc3_disable_irqs(kdwc); + err_irq: - clk_disable_unprepare(kdwc-clk); + pm_runtime_put_sync(dev); + pm_runtime_disable(dev); + clk_unprepare(kdwc-clk); return error; } @@ -172,7 +185,9 @@ static int kdwc3_remove(struct platform_device *pdev) kdwc3_disable_irqs(kdwc); device_for_each_child(pdev-dev, NULL, kdwc3_remove_core); - clk_disable_unprepare(kdwc-clk); + pm_runtime_put_sync(pdev-dev); + pm_runtime_disable(pdev-dev); + clk_unprepare(kdwc-clk); platform_set_drvdata(pdev, NULL); return 0; @@ -184,6 +199,79 @@ static const struct of_device_id kdwc3_of_match[] = { }; MODULE_DEVICE_TABLE(of, kdwc3_of_match); +static int __kdwc3_suspend(struct dwc3_keystone *kdwc) +{ + clk_disable(kdwc-clk); + + return 0; +} + +static int __kdwc3_resume(struct dwc3_keystone *kdwc) +{ + return clk_enable(kdwc-clk); +} + +static int kdwc3_prepare(struct device *dev) +{ + struct dwc3_keystone*kdwc = dev_get_drvdata(dev); + + kdwc3_disable_irqs(kdwc); + + return 0; +} + +static void kdwc3_complete(struct device *dev) +{ + struct dwc3_keystone*kdwc = dev_get_drvdata(dev); + + kdwc3_enable_irqs(kdwc); +} + +static int kdwc3_suspend(struct device *dev) +{ + struct dwc3_keystone*kdwc = dev_get_drvdata(dev); + + return __kdwc3_suspend(kdwc); +} + +static int kdwc3_resume(struct device *dev) +{ + struct dwc3_keystone*kdwc = dev_get_drvdata(dev); + int ret; + + ret = __kdwc3_resume(kdwc); + if (ret) + return ret; + + pm_runtime_disable(dev); + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + + return 0; +} + +static int kdwc3_runtime_suspend(struct device *dev) +{ + struct dwc3_keystone *kdwc = dev_get_drvdata(dev); + + return __kdwc3_suspend(kdwc); +} + +static int kdwc3_runtime_resume(struct device *dev) +{ + struct dwc3_keystone *kdwc = dev_get_drvdata(dev); + + return __kdwc3_resume(kdwc); +} + +static const struct dev_pm_ops kdwc3_dev_pm_ops = { + .prepare= kdwc3_prepare, + .complete = kdwc3_complete, + + SET_SYSTEM_SLEEP_PM_OPS(kdwc3_suspend, kdwc3_resume) + SET_RUNTIME_PM_OPS(kdwc3_runtime_suspend, kdwc3_runtime_resume, NULL) +}; + static struct platform_driver kdwc3_driver = { .probe = kdwc3_probe, .remove = kdwc3_remove, -- 1.8.4.GIT -- 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/7] usb: dwc3: keystone: add basic PM support
Hi, On Thu, Dec 12, 2013 at 03:45:55PM -0600, Felipe Balbi wrote: +static const struct dev_pm_ops kdwc3_dev_pm_ops = { + .prepare= kdwc3_prepare, + .complete = kdwc3_complete, + + SET_SYSTEM_SLEEP_PM_OPS(kdwc3_suspend, kdwc3_resume) + SET_RUNTIME_PM_OPS(kdwc3_runtime_suspend, kdwc3_runtime_resume, NULL) +}; did I really forget to use this ? Wonder why compiler didn't annoy me :-( there I go to v3. Will fix in my tree only to avoid the extra traffic in the mailing list. -- balbi signature.asc Description: Digital signature
[PATCH] usb: dwc3: omap: remove DEV_PM_OPS trickery
it's best to just remove all ifdefs and always define our dev_pm_ops structure. Signed-off-by: Felipe Balbi ba...@ti.com --- one more patch drivers/usb/dwc3/dwc3-omap.c | 8 +--- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index a9090a1..14a53ba 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c @@ -598,7 +598,6 @@ static const struct of_device_id of_dwc3_match[] = { }; MODULE_DEVICE_TABLE(of, of_dwc3_match); -#ifdef CONFIG_PM_SLEEP static int dwc3_omap_prepare(struct device *dev) { struct dwc3_omap*omap = dev_get_drvdata(dev); @@ -675,18 +674,13 @@ static const struct dev_pm_ops dwc3_omap_dev_pm_ops = { NULL) }; -#define DEV_PM_OPS (dwc3_omap_dev_pm_ops) -#else -#define DEV_PM_OPS NULL -#endif /* CONFIG_PM_SLEEP */ - static struct platform_driver dwc3_omap_driver = { .probe = dwc3_omap_probe, .remove = dwc3_omap_remove, .driver = { .name = omap-dwc3, .of_match_table = of_dwc3_match, - .pm = DEV_PM_OPS, + .pm = dwc3_omap_dev_pm_ops, }, }; -- 1.8.4.GIT -- 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 v5 3/9] usb: gadget: s3c-hsotg: enable build for other platforms
Hi Matt, On 12/12/13 7:26 AM, Matt Porter wrote: Remove unused Samsung-specific machine include and Kconfig dependency on S3C. Signed-off-by: Matt Porter mpor...@linaro.org Reviewed-by: Markus Mayer markus.ma...@linaro.org Reviewed-by: Tim Kryger tim.kry...@linaro.org --- drivers/usb/gadget/Kconfig | 7 +++ drivers/usb/gadget/s3c-hsotg.c | 2 -- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index a91e642..970bd1a 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -294,11 +294,10 @@ config USB_PXA27X gadget drivers to also be dynamically linked. config USB_S3C_HSOTG - tristate S3C HS/OtG USB Device controller - depends on S3C_DEV_USB_HSOTG + tristate Designware/S3C HS/OtG USB Device controller help - The Samsung S3C64XX USB2.0 high-speed gadget controller - integrated into the S3C64XX series SoC. + The Designware USB2.0 high-speed gadget controller + integrated into the S3C64XX and BCM281xx series SoC. Thanks for doing this. The SOCFPGA platform is also using this driver. So perhaps a more generic message here? Dinh config USB_S3C2410 tristate S3C2410 USB Device Controller diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index 33eb690..8ceb5ef 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c @@ -37,8 +37,6 @@ #include linux/usb/phy.h #include linux/platform_data/s3c-hsotg.h -#include mach/map.h - #include s3c-hsotg.h static const char * const s3c_hsotg_supply_names[] = { -- 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: dwc3: core: remove DWC3_PM_OPS
it's best to remove all ifdefs and always define our dev_pm-ops structure. Signed-off-by: Felipe Balbi ba...@ti.com --- drivers/usb/dwc3/core.c | 8 +--- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 74f9cf0..288e478 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -612,7 +612,6 @@ static int dwc3_remove(struct platform_device *pdev) return 0; } -#ifdef CONFIG_PM_SLEEP static int dwc3_prepare(struct device *dev) { struct dwc3 *dwc = dev_get_drvdata(dev); @@ -723,11 +722,6 @@ static const struct dev_pm_ops dwc3_dev_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(dwc3_suspend, dwc3_resume) }; -#define DWC3_PM_OPS(dwc3_dev_pm_ops) -#else -#define DWC3_PM_OPSNULL -#endif - #ifdef CONFIG_OF static const struct of_device_id of_dwc3_match[] = { { @@ -747,7 +741,7 @@ static struct platform_driver dwc3_driver = { .driver = { .name = dwc3, .of_match_table = of_match_ptr(of_dwc3_match), - .pm = DWC3_PM_OPS, + .pm = dwc3_dev_pm_ops, }, }; -- 1.8.4.GIT -- 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-storage] UAS hangs khubd on USB disconnect
On Wed, 11 Dec 2013, Sarah Sharp wrote: Hi Hans, I've been testing the UAS code you sent a pull request for against 3.13-rc1, and I've run into a rather nasty issue with USB disconnect. I ran some tests with a USB 3.0 storage device under xHCI. The disk has three 10GB partitions: ext3 (sdb1), ext4 (sdb2), and fat32 (sdb4). There was a btrfs partition on sdb3, but I deleted it. If I start to play a movie on the ext4 partition, and then yank the USB cable, the uas driver is unbound from the device. It looks like something goes wrong in the SCSI layer shortly after that, causing an oops in sysfs_remove_group(). I did a little testing. It turns out this WARN (not an oops) is the result of recent changes to sysfs, combined with the peculiar way the SCSI layer handles targets. In the new kernel, when you call device_del for some object, the object's directory and everything beneath it get removed from sysfs. This wasn't true in the past. When a USB drive is unplugged, almost everything below it gets unregistered. But not the SCSI target -- it remains registered until the number of reap references drops to 0. This doesn't happen until all the devices beneath it are released, which happens when all the open file references are closed and the filesystem is unmounted. So scsi_target_reap_usercontext ends up calling device_del for the target after everything else has been removed from sysfs. As part of normal device_del processing, attribute groups get removed. In particular the power/ subdirectory is removed from the target's sysfs directory. But the sysfs directories are long gone by this time, so sysfs_remove_group complains that it was asked to remove a non-existent subdirectory. Given the way things work now, I suspect these warnings are truly harmless. We could simply get rid of the WARN in sysfs_remove_group. The alternative is to call device_del for SCSI targets earlier on, such as when their hosts are unregistered. I don't know how James would feel about this approach. It would be difficult because targets use their own reference counts instead of relying on the usual device refcounting mechanism. Alan Stern -- 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 v5 3/9] usb: gadget: s3c-hsotg: enable build for other platforms
On Thu, Dec 12, 2013 at 03:51:31PM -0600, Dinh Nguyen wrote: Hi Matt, On 12/12/13 7:26 AM, Matt Porter wrote: Remove unused Samsung-specific machine include and Kconfig dependency on S3C. Signed-off-by: Matt Porter mpor...@linaro.org Reviewed-by: Markus Mayer markus.ma...@linaro.org Reviewed-by: Tim Kryger tim.kry...@linaro.org --- drivers/usb/gadget/Kconfig | 7 +++ drivers/usb/gadget/s3c-hsotg.c | 2 -- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index a91e642..970bd1a 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -294,11 +294,10 @@ config USB_PXA27X gadget drivers to also be dynamically linked. config USB_S3C_HSOTG - tristate S3C HS/OtG USB Device controller - depends on S3C_DEV_USB_HSOTG + tristate Designware/S3C HS/OtG USB Device controller help - The Samsung S3C64XX USB2.0 high-speed gadget controller - integrated into the S3C64XX series SoC. + The Designware USB2.0 high-speed gadget controller + integrated into the S3C64XX and BCM281xx series SoC. Thanks for doing this. The SOCFPGA platform is also using this driver. So perhaps a more generic message here? Ok, I wasn't aware since I didn't see anybody else try to fix this driver in mainline. How about this? The Designware USB2.0 high-speed gadget controller integrated into many SoCS. If that looks better to you I'll plan to add it in an update. I would like to see if we can gather a couple acks at this point or if there are any additional DT comments before sending another update. -Matt config USB_S3C2410 tristate S3C2410 USB Device Controller diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index 33eb690..8ceb5ef 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c @@ -37,8 +37,6 @@ #include linux/usb/phy.h #include linux/platform_data/s3c-hsotg.h -#include mach/map.h - #include s3c-hsotg.h static const char * const s3c_hsotg_supply_names[] = { -- 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 v5 3/9] usb: gadget: s3c-hsotg: enable build for other platforms
On 12/12/13 4:07 PM, Matt Porter wrote: On Thu, Dec 12, 2013 at 03:51:31PM -0600, Dinh Nguyen wrote: Hi Matt, On 12/12/13 7:26 AM, Matt Porter wrote: Remove unused Samsung-specific machine include and Kconfig dependency on S3C. Signed-off-by: Matt Porter mpor...@linaro.org Reviewed-by: Markus Mayer markus.ma...@linaro.org Reviewed-by: Tim Kryger tim.kry...@linaro.org --- drivers/usb/gadget/Kconfig | 7 +++ drivers/usb/gadget/s3c-hsotg.c | 2 -- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index a91e642..970bd1a 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -294,11 +294,10 @@ config USB_PXA27X gadget drivers to also be dynamically linked. config USB_S3C_HSOTG - tristate S3C HS/OtG USB Device controller - depends on S3C_DEV_USB_HSOTG + tristate Designware/S3C HS/OtG USB Device controller help - The Samsung S3C64XX USB2.0 high-speed gadget controller - integrated into the S3C64XX series SoC. + The Designware USB2.0 high-speed gadget controller + integrated into the S3C64XX and BCM281xx series SoC. Thanks for doing this. The SOCFPGA platform is also using this driver. So perhaps a more generic message here? Ok, I wasn't aware since I didn't see anybody else try to fix this driver in mainline. How about this? The Designware USB2.0 high-speed gadget controller integrated into many SoCS. That looks fine to me. Yeah, I didn't realize the s3c driver was just the Synopsys DWC2 peripheral driver until I saw drivers/staging/dwc2. I was in process of switching over to use it and then I saw your patchset. Thanks, Dinh If that looks better to you I'll plan to add it in an update. I would like to see if we can gather a couple acks at this point or if there are any additional DT comments before sending another update. -Matt config USB_S3C2410 tristate S3C2410 USB Device Controller diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index 33eb690..8ceb5ef 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c @@ -37,8 +37,6 @@ #include linux/usb/phy.h #include linux/platform_data/s3c-hsotg.h -#include mach/map.h - #include s3c-hsotg.h static const char * const s3c_hsotg_supply_names[] = { -- 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/2] usb: renesas_usbhs: remove original filter from usbhsf_dma_init()
Hi Felipe + chan = dma_request_slave_channel_compat(mask, + shdma_chan_filter, (void *)id, dev, name); this adds a build warning: drivers/usb/renesas_usbhs/fifo.c:1012:24: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] shdma_chan_filter, (void *)id, dev, name); Please fix it, I'll drop this patch for now. Thank you. shdma_chan_filer requests int id as void * somehow. I will fix it first, and send v2 patch after that. Thank you -- 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/7] usb: dwc3: keystone: add basic PM support
On Thursday 12 December 2013 04:45 PM, Felipe Balbi wrote: A bare-minimum PM implementation which will server as building block for more complex s/server/serve ;-) PM implementation in the future. At the least will not leave clocks on unnecessarily when e.g. a user write mem to /sys/power/state. Signed-off-by: Felipe Balbi ba...@ti.com --- improve error path a little bit. We will test this out. Thanks for the patch Felipe. Regards, Santosh -- 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/7] usb: dwc3: keystone: add basic PM support
On Thu, Dec 12, 2013 at 07:29:24PM -0500, Santosh Shilimkar wrote: On Thursday 12 December 2013 04:45 PM, Felipe Balbi wrote: A bare-minimum PM implementation which will server as building block for more complex s/server/serve ;-) hah! :-) will fix in my branch. PM implementation in the future. At the least will not leave clocks on unnecessarily when e.g. a user write mem to /sys/power/state. Signed-off-by: Felipe Balbi ba...@ti.com --- improve error path a little bit. We will test this out. Thanks for the patch Felipe. thanks. -- balbi signature.asc Description: Digital signature
Re: usb mass storage bug
On Thu, Oct 24, 2013 at 12:09:03PM -0400, Alan Stern wrote: On Thu, 24 Oct 2013, [iso-8859-2] J�nosi Zoli wrote: https://bugzilla.kernel.org/show_bug.cgi?id=63611 � Bug ID: 63611 Summary: cant connect sony phones in mass storage mode Is CONFIG_USB_OTG turned on in your kernel's .config? If it is, try building a new kernel with it turned off. Sorry for the long delay here. This got lost in my maildir for whatever reason. Felipe: Is the usb_enumerate_device_otg() routine really correct? It looks like it will try to enable HNP whenever CONFIG_USB_OTG is set, even if the root hub isn't OTG-capable. The routine does this: /* enable HNP before suspend, it's simpler */ if (port1 == bus-otg_port) bus-b_hnp_enable = 1; err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), USB_REQ_SET_FEATURE, 0, bus-b_hnp_enable ? USB_DEVICE_B_HNP_ENABLE : USB_DEVICE_A_ALT_HNP_SUPPORT, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); if (err 0) { /* OTG MESSAGE: report errors here, * customize to match your product. */ dev_info(udev-dev, can't set HNP mode: %d\n, err); bus-b_hnp_enable = 0; } Maybe the usb_control_msg and the error check should be inside the first if statement? I don't think so, see below: | static int usb_enumerate_device_otg(struct usb_device *udev) | { | int err = 0; | | #ifdefCONFIG_USB_OTG first, we know OTG is enabled. | /* |* OTG-aware devices on OTG-capable root hubs may be able to use SRP, |* to wake us after we've powered off VBUS; and HNP, switching roles |* host to peripheral. The OTG descriptor helps figure this out. |*/ | if (!udev-bus-is_b_host |udev-config |udev-parent == udev-bus-root_hub) { | struct usb_otg_descriptor *desc = NULL; | struct usb_bus *bus = udev-bus; | | /* descriptor may appear anywhere in config */ | if (__usb_get_extra_descriptor (udev-rawdescriptors[0], | le16_to_cpu(udev-config[0].desc.wTotalLength), | USB_DT_OTG, (void **) desc) == 0) { | if (desc-bmAttributes USB_OTG_HNP) { this check ensures the port supports HNP | unsignedport1 = udev-portnum; | | dev_info(udev-dev, | Dual-Role OTG device on %sHNP port\n, | (port1 == bus-otg_port) | ? : non-); | | /* enable HNP before suspend, it's simpler */ | if (port1 == bus-otg_port) | bus-b_hnp_enable = 1; this check tells is just to help you choose between enabling HNP on a B device, or telling the device that another root hub port supports HNP | err = usb_control_msg(udev, | usb_sndctrlpipe(udev, 0), | USB_REQ_SET_FEATURE, 0, | bus-b_hnp_enable | ? USB_DEVICE_B_HNP_ENABLE | : USB_DEVICE_A_ALT_HNP_SUPPORT, so, based on this, we're just enabling HNP on the device, but HNP won't kick in until the root hub port is suspended. | 0, NULL, 0, USB_CTRL_SET_TIMEOUT); | if (err 0) { | /* OTG MESSAGE: report errors here, |* customize to match your product. |*/ | dev_info(udev-dev, | can't set HNP mode: %d\n, | err); | bus-b_hnp_enable = 0; | } | } | } | } | | if (!is_targeted(udev)) { and, BTW, this needs to change. We shouldn't have a TPL *in* the kernel
[PATCH] usb: host: xhci: Move suspend ops under PM_SLEEP to avoid warning
Otherwise you get below build warnings drivers/usb/host/xhci-plat.c:201:12: warning: ‘xhci_plat_suspend’ defined but not used [-Wunused-function] drivers/usb/host/xhci-plat.c:209:12: warning: ‘xhci_plat_resume’ defined but not used [-Wunused-function] Cc: Sarah Sharp sarah.a.sh...@linux.intel.com Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Signed-off-by: Santosh Shilimkar santosh.shilim...@ti.com --- drivers/usb/host/xhci-plat.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index d9c169f..4875be5 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -197,7 +197,7 @@ static int xhci_plat_remove(struct platform_device *dev) return 0; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int xhci_plat_suspend(struct device *dev) { struct usb_hcd *hcd = dev_get_drvdata(dev); @@ -220,7 +220,7 @@ static const struct dev_pm_ops xhci_plat_pm_ops = { #define DEV_PM_OPS (xhci_plat_pm_ops) #else #define DEV_PM_OPS NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ #ifdef CONFIG_OF static const struct of_device_id usb_xhci_of_match[] = { -- 1.7.9.5 -- 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: host: xhci: Move suspend ops under PM_SLEEP to avoid warning
On Thu, Dec 12, 2013 at 08:06:24PM -0500, Santosh Shilimkar wrote: Otherwise you get below build warnings drivers/usb/host/xhci-plat.c:201:12: warning: ‘xhci_plat_suspend’ defined but not used [-Wunused-function] drivers/usb/host/xhci-plat.c:209:12: warning: ‘xhci_plat_resume’ defined but not used [-Wunused-function] Cc: Sarah Sharp sarah.a.sh...@linux.intel.com Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Signed-off-by: Santosh Shilimkar santosh.shilim...@ti.com --- drivers/usb/host/xhci-plat.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index d9c169f..4875be5 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -197,7 +197,7 @@ static int xhci_plat_remove(struct platform_device *dev) return 0; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP Can't you just remove these #ifdefs altogether? xhci_plat_pm_ops is set using SET_SYSTEM_SLEEP_PM_OPS() macro which already handles '#ifdef CONFIG_PM_SLEEP' case. static int xhci_plat_suspend(struct device *dev) { struct usb_hcd *hcd = dev_get_drvdata(dev); @@ -220,7 +220,7 @@ static const struct dev_pm_ops xhci_plat_pm_ops = { #define DEV_PM_OPS (xhci_plat_pm_ops) #else #define DEV_PM_OPS NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ Ditto. Br, David Cohen #ifdef CONFIG_OF static const struct of_device_id usb_xhci_of_match[] = { -- 1.7.9.5 -- 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 -- 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/7] usb: dwc3: pci: add pm_runtime support
On Thu, Dec 12, 2013 at 03:38:41PM -0600, Felipe Balbi wrote: teach the PCI glue about pm_runtime so that it's easier to teach dwc3 core about it later. No functional changes otherwise. Signed-off-by: Felipe Balbi ba...@ti.com I was able to test this one with Intel Merrifield: Acked-by: David Cohen david.a.co...@linux.intel.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
[PATCH v6 05/15] ARM: dts: imx6: add anatop phandle for usbphy
Add anatop phandle for usbphy Signed-off-by: Peter Chen peter.c...@freescale.com --- arch/arm/boot/dts/imx6qdl.dtsi |2 ++ arch/arm/boot/dts/imx6sl.dtsi |2 ++ 2 files changed, 4 insertions(+), 0 deletions(-) diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi index 59154dc..4e74962 100644 --- a/arch/arm/boot/dts/imx6qdl.dtsi +++ b/arch/arm/boot/dts/imx6qdl.dtsi @@ -557,6 +557,7 @@ reg = 0x020c9000 0x1000; interrupts = 0 44 0x04; clocks = clks 182; + fsl,anatop = anatop; }; usbphy2: usbphy@020ca000 { @@ -564,6 +565,7 @@ reg = 0x020ca000 0x1000; interrupts = 0 45 0x04; clocks = clks 183; + fsl,anatop = anatop; }; snvs@020cc000 { diff --git a/arch/arm/boot/dts/imx6sl.dtsi b/arch/arm/boot/dts/imx6sl.dtsi index 28558f1..30322b5 100644 --- a/arch/arm/boot/dts/imx6sl.dtsi +++ b/arch/arm/boot/dts/imx6sl.dtsi @@ -489,6 +489,7 @@ reg = 0x020c9000 0x1000; interrupts = 0 44 0x04; clocks = clks IMX6SL_CLK_USBPHY1; + fsl,anatop = anatop; }; usbphy2: usbphy@020ca000 { @@ -496,6 +497,7 @@ reg = 0x020ca000 0x1000; interrupts = 0 45 0x04; clocks = clks IMX6SL_CLK_USBPHY2; + fsl,anatop = anatop; }; snvs@020cc000 { -- 1.7.8 -- 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 v6 00/15] Add power management support for mxs phy
Hi Felipe Shawn, The serial adds power management support for MXS PHY, it includes: - Add three common PHY APIs, .set_wakeup, .notify_suspend, notify_resume. - Related above API implementation at mxs phy driver - misc changes and bug fixes for mxs phy to support low power mode and wakeup. It is based on Greg's usb-next, 3.13-rc1. Changes for v6: - Add description for IC bug fixes logic. [9/15] - Move is_imx6q_phy and is_imx6sl_phy from [9/15] to [14/15] - %s/mxs_phy_clock_switch/mxs_phy_clock_switch_delay to reflect the function meaning more precise [15/15] Changes for v5: Add Marc and Michael Grzeschik's commnets - typo error at [2/15] - sqhash patches which introducing mxs_phy_disconnect_line and fixed but at this function. [13/15] - Introducing flag MXS_PHY_NEED_IP_FIX who stands for the SoCs who have IC fixes. [2/15, 8/15] - Delete one patch for low speed connection problem at every rare situations due to the root cause has still not found. Peter Chen (15): usb: doc: phy-mxs: Add more compatible strings usb: phy-mxs: Add platform judgement code usb: phy-mxs: Add auto clock and power setting usb: doc: phy-mxs: update binding for adding anatop phandle ARM: dts: imx6: add anatop phandle for usbphy usb: phy-mxs: Add anatop regmap usb: phy: add notify suspend and resume callback usb: phy-mxs: Add implementation of nofity_suspend and notify_resume usb: phy-mxs: Enable IC fixes for related SoCs ARM: dts: imx: add mxs phy controller id usb: phy-mxs: add controller id usb: phy: Add set_wakeup API usb: phy-mxs: Add implementation of set_wakeup usb: phy-mxs: Add system suspend/resume API usb: phy-mxs: Add sync time after controller clear phcd Documentation/devicetree/bindings/usb/mxs-phy.txt |5 +- arch/arm/boot/dts/imx23.dtsi |1 + arch/arm/boot/dts/imx28.dtsi |2 + arch/arm/boot/dts/imx6qdl.dtsi|4 + arch/arm/boot/dts/imx6sl.dtsi |4 + drivers/usb/phy/phy-mxs-usb.c | 360 - include/linux/usb/phy.h | 39 +++ 7 files changed, 400 insertions(+), 15 deletions(-) -- 1.7.8 -- 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 v6 04/15] usb: doc: phy-mxs: update binding for adding anatop phandle
Add anatop phandle which is used to access anatop registers to control PHY's power and other USB operations. Signed-off-by: Peter Chen peter.c...@freescale.com --- Documentation/devicetree/bindings/usb/mxs-phy.txt |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/mxs-phy.txt b/Documentation/devicetree/bindings/usb/mxs-phy.txt index d850e55..059536c 100644 --- a/Documentation/devicetree/bindings/usb/mxs-phy.txt +++ b/Documentation/devicetree/bindings/usb/mxs-phy.txt @@ -5,10 +5,12 @@ Required properties: for imx6dq and imx6dl, fsl,imx6sl-usbphy for imx6sl - reg: Should contain registers location and length - interrupts: Should contain phy interrupt +- fsl,anatop: phandle for anatop register, it is only for imx6 SoC series Example: usbphy1: usbphy@020c9000 { compatible = fsl,imx6q-usbphy, fsl,imx23-usbphy; reg = 0x020c9000 0x1000; interrupts = 0 44 0x04; + fsl,anatop = anatop; }; -- 1.7.8 -- 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 v6 06/15] usb: phy-mxs: Add anatop regmap
It is needed by imx6 SoC series, but not for imx23 and imx28. Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/phy/phy-mxs-usb.c | 23 +-- 1 files changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index 0c6f3bc..0ef930a 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c @@ -21,6 +21,8 @@ #include linux/err.h #include linux/io.h #include linux/of_device.h +#include linux/regmap.h +#include linux/mfd/syscon.h #define DRIVER_NAME mxs_phy @@ -58,6 +60,9 @@ */ #define MXS_PHY_SENDING_SOF_TOO_FAST BIT(2) +/* The SoCs who have anatop module */ +#define MXS_PHY_HAS_ANATOP BIT(3) + struct mxs_phy_data { unsigned int flags; }; @@ -68,11 +73,13 @@ static const struct mxs_phy_data imx23_phy_data = { static const struct mxs_phy_data imx6q_phy_data = { .flags = MXS_PHY_SENDING_SOF_TOO_FAST | - MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS, + MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS | + MXS_PHY_HAS_ANATOP, }; static const struct mxs_phy_data imx6sl_phy_data = { - .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS, + .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS | + MXS_PHY_HAS_ANATOP, }; static const struct of_device_id mxs_phy_dt_ids[] = { @@ -87,6 +94,7 @@ struct mxs_phy { struct usb_phy phy; struct clk *clk; const struct mxs_phy_data *data; + struct regmap *regmap_anatop; }; static int mxs_phy_hw_init(struct mxs_phy *mxs_phy) @@ -190,6 +198,7 @@ static int mxs_phy_probe(struct platform_device *pdev) int ret; const struct of_device_id *of_id = of_match_device(mxs_phy_dt_ids, pdev-dev); + struct device_node *np = pdev-dev.of_node; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_ioremap_resource(pdev-dev, res); @@ -226,6 +235,16 @@ static int mxs_phy_probe(struct platform_device *pdev) platform_set_drvdata(pdev, mxs_phy); + if (mxs_phy-data-flags MXS_PHY_HAS_ANATOP) { + mxs_phy-regmap_anatop = syscon_regmap_lookup_by_phandle + (np, fsl,anatop); + if (IS_ERR(mxs_phy-regmap_anatop)) { + dev_dbg(pdev-dev, + failed to find regmap for anatop\n); + return PTR_ERR(mxs_phy-regmap_anatop); + } + } + ret = usb_add_phy_dev(mxs_phy-phy); if (ret) return ret; -- 1.7.8 -- 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 v6 09/15] usb: phy-mxs: Enable IC fixes for related SoCs
Two PHY bugs are fixed by IC logic, but these bits are not enabled by default, so we enable them at driver. The two bugs are: MXS_PHY_ABNORMAL_IN_SUSPEND and MXS_PHY_SENDING_SOF_TOO_FAST which are described at code. Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/phy/phy-mxs-usb.c | 23 +-- 1 files changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index e3df53f..b446cc2 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c @@ -31,6 +31,10 @@ #define HW_USBPHY_CTRL_SET 0x34 #define HW_USBPHY_CTRL_CLR 0x38 +#define HW_USBPHY_IP 0x90 +#define HW_USBPHY_IP_SET 0x94 +#define HW_USBPHY_IP_CLR 0x98 + #define BM_USBPHY_CTRL_SFTRST BIT(31) #define BM_USBPHY_CTRL_CLKGATE BIT(30) #define BM_USBPHY_CTRL_ENAUTOSET_USBCLKS BIT(26) @@ -42,6 +46,8 @@ #define BM_USBPHY_CTRL_ENUTMILEVEL2BIT(14) #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT BIT(1) +#define BM_USBPHY_IP_FIX (BIT(17) | BIT(18)) + #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy) /* Do disconnection between PHY and controller without vbus */ @@ -63,6 +69,14 @@ /* The SoCs who have anatop module */ #define MXS_PHY_HAS_ANATOP BIT(3) +/* + * IC has bug fixes logic, they include + * MXS_PHY_ABNORMAL_IN_SUSPEND and MXS_PHY_SENDING_SOF_TOO_FAST + * which are described at above flags, the RTL will handle it + * according to different versions. + */ +#define MXS_PHY_NEED_IP_FIXBIT(4) + struct mxs_phy_data { unsigned int flags; }; @@ -74,12 +88,14 @@ static const struct mxs_phy_data imx23_phy_data = { static const struct mxs_phy_data imx6q_phy_data = { .flags = MXS_PHY_SENDING_SOF_TOO_FAST | MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS | - MXS_PHY_HAS_ANATOP, + MXS_PHY_HAS_ANATOP | + MXS_PHY_NEED_IP_FIX, }; static const struct mxs_phy_data imx6sl_phy_data = { .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS | - MXS_PHY_HAS_ANATOP, + MXS_PHY_HAS_ANATOP | + MXS_PHY_NEED_IP_FIX, }; static const struct of_device_id mxs_phy_dt_ids[] = { @@ -123,6 +139,9 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy) BM_USBPHY_CTRL_ENUTMILEVEL3, base + HW_USBPHY_CTRL_SET); + if (mxs_phy-data-flags MXS_PHY_NEED_IP_FIX) + writel(BM_USBPHY_IP_FIX, base + HW_USBPHY_IP_SET); + return 0; } -- 1.7.8 -- 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 v6 08/15] usb: phy-mxs: Add implementation of nofity_suspend and notify_resume
Implementation of notify_suspend and notify_resume will be different according to mxs_phy_data-flags. Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/phy/phy-mxs-usb.c | 55 ++--- 1 files changed, 51 insertions(+), 4 deletions(-) diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index 0ef930a..e3df53f 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c @@ -166,8 +166,8 @@ static int mxs_phy_suspend(struct usb_phy *x, int suspend) static int mxs_phy_on_connect(struct usb_phy *phy, enum usb_device_speed speed) { - dev_dbg(phy-dev, %s speed device has connected\n, - (speed == USB_SPEED_HIGH) ? high : non-high); + dev_dbg(phy-dev, %s device has connected\n, + (speed == USB_SPEED_HIGH) ? HS : FS/LS); if (speed == USB_SPEED_HIGH) writel(BM_USBPHY_CTRL_ENHOSTDISCONDETECT, @@ -179,8 +179,8 @@ static int mxs_phy_on_connect(struct usb_phy *phy, static int mxs_phy_on_disconnect(struct usb_phy *phy, enum usb_device_speed speed) { - dev_dbg(phy-dev, %s speed device has disconnected\n, - (speed == USB_SPEED_HIGH) ? high : non-high); + dev_dbg(phy-dev, %s device has disconnected\n, + (speed == USB_SPEED_HIGH) ? HS : FS/LS); if (speed == USB_SPEED_HIGH) writel(BM_USBPHY_CTRL_ENHOSTDISCONDETECT, @@ -189,6 +189,48 @@ static int mxs_phy_on_disconnect(struct usb_phy *phy, return 0; } +static int mxs_phy_on_suspend(struct usb_phy *phy, + enum usb_device_speed speed) +{ + struct mxs_phy *mxs_phy = to_mxs_phy(phy); + + dev_dbg(phy-dev, %s device has suspended\n, + (speed == USB_SPEED_HIGH) ? HS : FS/LS); + + /* delay 4ms to wait bus entering idle */ + usleep_range(4000, 5000); + + if (mxs_phy-data-flags MXS_PHY_ABNORMAL_IN_SUSPEND) { + writel_relaxed(0x, phy-io_priv + HW_USBPHY_PWD); + writel_relaxed(0, phy-io_priv + HW_USBPHY_PWD); + } + + if (speed == USB_SPEED_HIGH) + writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT, + phy-io_priv + HW_USBPHY_CTRL_CLR); + + return 0; +} + +/* + * The resume signal must be finished here. + */ +static int mxs_phy_on_resume(struct usb_phy *phy, + enum usb_device_speed speed) +{ + dev_dbg(phy-dev, %s device has resumed\n, + (speed == USB_SPEED_HIGH) ? HS : FS/LS); + + if (speed == USB_SPEED_HIGH) { + /* Make sure the device has switched to High-Speed mode */ + udelay(500); + writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT, + phy-io_priv + HW_USBPHY_CTRL_SET); + } + + return 0; +} + static int mxs_phy_probe(struct platform_device *pdev) { struct resource *res; @@ -235,6 +277,11 @@ static int mxs_phy_probe(struct platform_device *pdev) platform_set_drvdata(pdev, mxs_phy); + if (mxs_phy-data-flags MXS_PHY_SENDING_SOF_TOO_FAST) { + mxs_phy-phy.notify_suspend = mxs_phy_on_suspend; + mxs_phy-phy.notify_resume = mxs_phy_on_resume; + } + if (mxs_phy-data-flags MXS_PHY_HAS_ANATOP) { mxs_phy-regmap_anatop = syscon_regmap_lookup_by_phandle (np, fsl,anatop); -- 1.7.8 -- 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 v6 02/15] usb: phy-mxs: Add platform judgement code
The mxs-phy has several bugs and features at different versions, the driver code can get it through of_device_id.data. Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/phy/phy-mxs-usb.c | 58 ++-- 1 files changed, 49 insertions(+), 9 deletions(-) diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index 545844b..6d49040 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Freescale Semiconductor, Inc. + * Copyright 2012-2013 Freescale Semiconductor, Inc. * Copyright (C) 2012 Marek Vasut ma...@denx.de * on behalf of DENX Software Engineering GmbH * @@ -20,6 +20,7 @@ #include linux/delay.h #include linux/err.h #include linux/io.h +#include linux/of_device.h #define DRIVER_NAME mxs_phy @@ -34,13 +35,55 @@ #define BM_USBPHY_CTRL_ENUTMILEVEL2BIT(14) #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT BIT(1) +#define to_mxs_phy(p) container_of((p), struct mxs_phy, phy) + +/* Do disconnection between PHY and controller without vbus */ +#define MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS BIT(0) + +/* + * The PHY will be in messy if there is a wakeup after putting + * bus to suspend (set portsc.suspendM) but before setting PHY to low + * power mode (set portsc.phcd). + */ +#define MXS_PHY_ABNORMAL_IN_SUSPENDBIT(1) + +/* + * The SOF sends too fast after resuming, it will cause disconnection + * between host and high speed device. + */ +#define MXS_PHY_SENDING_SOF_TOO_FAST BIT(2) + +struct mxs_phy_data { + unsigned int flags; +}; + +static const struct mxs_phy_data imx23_phy_data = { + .flags = MXS_PHY_ABNORMAL_IN_SUSPEND | MXS_PHY_SENDING_SOF_TOO_FAST, +}; + +static const struct mxs_phy_data imx6q_phy_data = { + .flags = MXS_PHY_SENDING_SOF_TOO_FAST | + MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS, +}; + +static const struct mxs_phy_data imx6sl_phy_data = { + .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS, +}; + +static const struct of_device_id mxs_phy_dt_ids[] = { + { .compatible = fsl,imx6sl-usbphy, .data = imx6sl_phy_data, }, + { .compatible = fsl,imx6q-usbphy, .data = imx6q_phy_data, }, + { .compatible = fsl,imx23-usbphy, .data = imx23_phy_data, }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, mxs_phy_dt_ids); + struct mxs_phy { struct usb_phy phy; struct clk *clk; + const struct mxs_phy_data *data; }; -#define to_mxs_phy(p) container_of((p), struct mxs_phy, phy) - static int mxs_phy_hw_init(struct mxs_phy *mxs_phy) { int ret; @@ -131,6 +174,8 @@ static int mxs_phy_probe(struct platform_device *pdev) struct clk *clk; struct mxs_phy *mxs_phy; int ret; + const struct of_device_id *of_id = + of_match_device(mxs_phy_dt_ids, pdev-dev); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_ioremap_resource(pdev-dev, res); @@ -163,6 +208,7 @@ static int mxs_phy_probe(struct platform_device *pdev) ATOMIC_INIT_NOTIFIER_HEAD(mxs_phy-phy.notifier); mxs_phy-clk = clk; + mxs_phy-data = of_id-data; platform_set_drvdata(pdev, mxs_phy); @@ -182,12 +228,6 @@ static int mxs_phy_remove(struct platform_device *pdev) return 0; } -static const struct of_device_id mxs_phy_dt_ids[] = { - { .compatible = fsl,imx23-usbphy, }, - { /* sentinel */ } -}; -MODULE_DEVICE_TABLE(of, mxs_phy_dt_ids); - static struct platform_driver mxs_phy_driver = { .probe = mxs_phy_probe, .remove = mxs_phy_remove, -- 1.7.8 -- 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 v6 07/15] usb: phy: add notify suspend and resume callback
They are used to notify PHY that the controller enters suspend or finishes resume. Signed-off-by: Peter Chen peter.c...@freescale.com --- include/linux/usb/phy.h | 23 +++ 1 files changed, 23 insertions(+), 0 deletions(-) diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h index 6c0b1c5..a747960 100644 --- a/include/linux/usb/phy.h +++ b/include/linux/usb/phy.h @@ -116,6 +116,11 @@ struct usb_phy { enum usb_device_speed speed); int (*notify_disconnect)(struct usb_phy *x, enum usb_device_speed speed); + int (*notify_suspend)(struct usb_phy *x, + enum usb_device_speed speed); + int (*notify_resume)(struct usb_phy *x, + enum usb_device_speed speed); + }; /** @@ -282,6 +287,24 @@ usb_phy_notify_disconnect(struct usb_phy *x, enum usb_device_speed speed) return 0; } +static inline int usb_phy_notify_suspend + (struct usb_phy *x, enum usb_device_speed speed) +{ + if (x x-notify_suspend) + return x-notify_suspend(x, speed); + else + return 0; +} + +static inline int usb_phy_notify_resume + (struct usb_phy *x, enum usb_device_speed speed) +{ + if (x x-notify_resume) + return x-notify_resume(x, speed); + else + return 0; +} + /* notifiers */ static inline int usb_register_notifier(struct usb_phy *x, struct notifier_block *nb) -- 1.7.8 -- 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 v6 12/15] usb: phy: Add set_wakeup API
This API is used to set wakeup enable at PHY registers, in that case, the PHY can be waken up from suspend due to external events, like vbus change, dp/dm change and id change. Signed-off-by: Peter Chen peter.c...@freescale.com --- include/linux/usb/phy.h | 16 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h index a747960..c6ebe1d 100644 --- a/include/linux/usb/phy.h +++ b/include/linux/usb/phy.h @@ -111,6 +111,13 @@ struct usb_phy { int (*set_suspend)(struct usb_phy *x, int suspend); + /* +* Set wakeup enable for PHY, in that case, the PHY can be +* waken up from suspend status due to external events, +* like vbus change, dp/dm change and id. +*/ + int (*set_wakeup)(struct usb_phy *x, bool enabled); + /* notify phy connect status change */ int (*notify_connect)(struct usb_phy *x, enum usb_device_speed speed); @@ -270,6 +277,15 @@ usb_phy_set_suspend(struct usb_phy *x, int suspend) } static inline int +usb_phy_set_wakeup(struct usb_phy *x, bool enabled) +{ + if (x x-set_wakeup) + return x-set_wakeup(x, enabled); + else + return 0; +} + +static inline int usb_phy_notify_connect(struct usb_phy *x, enum usb_device_speed speed) { if (x x-notify_connect) -- 1.7.8 -- 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 v6 01/15] usb: doc: phy-mxs: Add more compatible strings
Add fsl,imx6q-usbphy for imx6dq and imx6dl, add fsl,imx6sl-usbphy for imx6sl. Signed-off-by: Peter Chen peter.c...@freescale.com --- Documentation/devicetree/bindings/usb/mxs-phy.txt |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/mxs-phy.txt b/Documentation/devicetree/bindings/usb/mxs-phy.txt index 5835b27..d850e55 100644 --- a/Documentation/devicetree/bindings/usb/mxs-phy.txt +++ b/Documentation/devicetree/bindings/usb/mxs-phy.txt @@ -1,7 +1,8 @@ * Freescale MXS USB Phy Device Required properties: -- compatible: Should be fsl,imx23-usbphy +- compatible: fsl,imx23-usbphy for imx23 and imx28, fsl,imx6q-usbphy +for imx6dq and imx6dl, fsl,imx6sl-usbphy for imx6sl - reg: Should contain registers location and length - interrupts: Should contain phy interrupt -- 1.7.8 -- 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 v6 13/15] usb: phy-mxs: Add implementation of set_wakeup
When we need the PHY can be waken up by external signals, we can call this API. Besides, we call mxs_phy_disconnect_line at this API to close the connection between USB PHY and controller, after that, the line state from controller is SE0. Once the PHY is out of power, without calling mxs_phy_disconnect_line, there are unknown wakeups due to dp/dm floating at device mode. Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/phy/phy-mxs-usb.c | 116 + 1 files changed, 116 insertions(+), 0 deletions(-) diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index 5649970..1bf78ee 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c @@ -31,6 +31,9 @@ #define HW_USBPHY_CTRL_SET 0x34 #define HW_USBPHY_CTRL_CLR 0x38 +#define HW_USBPHY_DEBUG_SET0x54 +#define HW_USBPHY_DEBUG_CLR0x58 + #define HW_USBPHY_IP 0x90 #define HW_USBPHY_IP_SET 0x94 #define HW_USBPHY_IP_CLR 0x98 @@ -39,6 +42,9 @@ #define BM_USBPHY_CTRL_CLKGATE BIT(30) #define BM_USBPHY_CTRL_ENAUTOSET_USBCLKS BIT(26) #define BM_USBPHY_CTRL_ENAUTOCLR_USBCLKGATEBIT(25) +#define BM_USBPHY_CTRL_ENVBUSCHG_WKUP BIT(23) +#define BM_USBPHY_CTRL_ENIDCHG_WKUPBIT(22) +#define BM_USBPHY_CTRL_ENDPDMCHG_WKUP BIT(21) #define BM_USBPHY_CTRL_ENAUTOCLR_PHY_PWD BIT(20) #define BM_USBPHY_CTRL_ENAUTOCLR_CLKGATE BIT(19) #define BM_USBPHY_CTRL_ENAUTO_PWRON_PLLBIT(18) @@ -48,6 +54,25 @@ #define BM_USBPHY_IP_FIX (BIT(17) | BIT(18)) +#define BM_USBPHY_DEBUG_CLKGATEBIT(30) + +/* Anatop Registers */ +#define ANADIG_USB1_VBUS_DET_STAT 0x1c0 +#define ANADIG_USB2_VBUS_DET_STAT 0x220 + +#define ANADIG_USB1_LOOPBACK_SET 0x1e4 +#define ANADIG_USB1_LOOPBACK_CLR 0x1e8 +#define ANADIG_USB2_LOOPBACK_SET 0x244 +#define ANADIG_USB2_LOOPBACK_CLR 0x248 + +#define BM_ANADIG_USB1_VBUS_DET_STAT_VBUS_VALIDBIT(3) +#define BM_ANADIG_USB2_VBUS_DET_STAT_VBUS_VALIDBIT(3) + +#define BM_ANADIG_USB1_LOOPBACK_UTMI_DIG_TST1 BIT(2) +#define BM_ANADIG_USB1_LOOPBACK_TSTI_TX_EN BIT(5) +#define BM_ANADIG_USB2_LOOPBACK_UTMI_DIG_TST1 BIT(2) +#define BM_ANADIG_USB2_LOOPBACK_TSTI_TX_EN BIT(5) + #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy) /* Do disconnection between PHY and controller without vbus */ @@ -146,6 +171,79 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy) return 0; } +/* Return true if the vbus is there */ +static bool mxs_phy_get_vbus_status(struct mxs_phy *mxs_phy) +{ + unsigned int vbus_value; + + if (mxs_phy-port_id == 0) + regmap_read(mxs_phy-regmap_anatop, + ANADIG_USB1_VBUS_DET_STAT, + vbus_value); + else if (mxs_phy-port_id == 1) + regmap_read(mxs_phy-regmap_anatop, + ANADIG_USB2_VBUS_DET_STAT, + vbus_value); + + if (vbus_value BM_ANADIG_USB1_VBUS_DET_STAT_VBUS_VALID) + return true; + else + return false; +} + +static void __mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool disconnect) +{ + void __iomem *base = mxs_phy-phy.io_priv; + u32 reg; + + if (disconnect) + writel_relaxed(BM_USBPHY_DEBUG_CLKGATE, + base + HW_USBPHY_DEBUG_CLR); + + if (mxs_phy-port_id == 0) { + reg = disconnect ? ANADIG_USB1_LOOPBACK_SET + : ANADIG_USB1_LOOPBACK_CLR; + regmap_write(mxs_phy-regmap_anatop, reg, + BM_ANADIG_USB1_LOOPBACK_UTMI_DIG_TST1 | + BM_ANADIG_USB1_LOOPBACK_TSTI_TX_EN); + } else if (mxs_phy-port_id == 1) { + reg = disconnect ? ANADIG_USB2_LOOPBACK_SET + : ANADIG_USB2_LOOPBACK_CLR; + regmap_write(mxs_phy-regmap_anatop, reg, + BM_ANADIG_USB2_LOOPBACK_UTMI_DIG_TST1 | + BM_ANADIG_USB2_LOOPBACK_TSTI_TX_EN); + } + + if (!disconnect) + writel_relaxed(BM_USBPHY_DEBUG_CLKGATE, + base + HW_USBPHY_DEBUG_SET); + + /* Delay some time, and let Linestate be SE0 for controller */ + if (disconnect) + usleep_range(500, 1000); +} + +static void mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool on) +{ + bool vbus_is_on = false; + + /* If the SoCs don't need to disconnect line without vbus, quit */ + if (!(mxs_phy-data-flags MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS)) + return; + + /* If the SoCs don't have anatop, quit */ + if (!mxs_phy-regmap_anatop) +
[PATCH v6 03/15] usb: phy-mxs: Add auto clock and power setting
With the auto setting, the PHY's clock and power can be recovered correctly from low power mode, it is ganranteed by IC logic. Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/phy/phy-mxs-usb.c | 20 +--- 1 files changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index 6d49040..0c6f3bc 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c @@ -31,6 +31,11 @@ #define BM_USBPHY_CTRL_SFTRST BIT(31) #define BM_USBPHY_CTRL_CLKGATE BIT(30) +#define BM_USBPHY_CTRL_ENAUTOSET_USBCLKS BIT(26) +#define BM_USBPHY_CTRL_ENAUTOCLR_USBCLKGATEBIT(25) +#define BM_USBPHY_CTRL_ENAUTOCLR_PHY_PWD BIT(20) +#define BM_USBPHY_CTRL_ENAUTOCLR_CLKGATE BIT(19) +#define BM_USBPHY_CTRL_ENAUTO_PWRON_PLLBIT(18) #define BM_USBPHY_CTRL_ENUTMILEVEL3BIT(15) #define BM_USBPHY_CTRL_ENUTMILEVEL2BIT(14) #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT BIT(1) @@ -96,9 +101,18 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy) /* Power up the PHY */ writel(0, base + HW_USBPHY_PWD); - /* enable FS/LS device */ - writel(BM_USBPHY_CTRL_ENUTMILEVEL2 | - BM_USBPHY_CTRL_ENUTMILEVEL3, + /* +* USB PHY Ctrl Setting +* - Auto clock/power on +* - Enable full/low speed support +*/ + writel(BM_USBPHY_CTRL_ENAUTOSET_USBCLKS | + BM_USBPHY_CTRL_ENAUTOCLR_USBCLKGATE | + BM_USBPHY_CTRL_ENAUTOCLR_PHY_PWD | + BM_USBPHY_CTRL_ENAUTOCLR_CLKGATE | + BM_USBPHY_CTRL_ENAUTO_PWRON_PLL | + BM_USBPHY_CTRL_ENUTMILEVEL2 | + BM_USBPHY_CTRL_ENUTMILEVEL3, base + HW_USBPHY_CTRL_SET); return 0; -- 1.7.8 -- 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 v6 11/15] usb: phy-mxs: add controller id
It is used to access un-regulator registers according to different controllers. Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/phy/phy-mxs-usb.c |8 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index b446cc2..5649970 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c @@ -111,6 +111,7 @@ struct mxs_phy { struct clk *clk; const struct mxs_phy_data *data; struct regmap *regmap_anatop; + int port_id; }; static int mxs_phy_hw_init(struct mxs_phy *mxs_phy) @@ -279,6 +280,13 @@ static int mxs_phy_probe(struct platform_device *pdev) return -ENOMEM; } + ret = of_alias_get_id(np, usbphy); + if (ret 0) { + dev_err(pdev-dev, failed to get alias id, errno %d\n, ret); + return ret; + } + mxs_phy-port_id = ret; + mxs_phy-phy.io_priv= base; mxs_phy-phy.dev= pdev-dev; mxs_phy-phy.label = DRIVER_NAME; -- 1.7.8 -- 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 v6 15/15] usb: phy-mxs: Add sync time after controller clear phcd
After clear portsc.phcd, PHY needs 200us stable time for switch 32K clock to AHB clock. Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/phy/phy-mxs-usb.c | 11 +++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index 885f8d9..68bd981 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c @@ -156,6 +156,15 @@ static inline bool is_imx6sl_phy(struct mxs_phy *mxs_phy) return mxs_phy-data == imx6sl_phy_data; } +/* + * PHY needs some 32K cycles to switch from 32K clock to + * bus (such as AHB/AXI, etc) clock. + */ +static void mxs_phy_clock_switch_delay(void) +{ + usleep_range(300, 400); +} + static int mxs_phy_hw_init(struct mxs_phy *mxs_phy) { int ret; @@ -281,6 +290,7 @@ static int mxs_phy_init(struct usb_phy *phy) { struct mxs_phy *mxs_phy = to_mxs_phy(phy); + mxs_phy_clock_switch_delay(); clk_prepare_enable(mxs_phy-clk); return mxs_phy_hw_init(mxs_phy); } @@ -305,6 +315,7 @@ static int mxs_phy_suspend(struct usb_phy *x, int suspend) x-io_priv + HW_USBPHY_CTRL_SET); clk_disable_unprepare(mxs_phy-clk); } else { + mxs_phy_clock_switch_delay(); clk_prepare_enable(mxs_phy-clk); writel(BM_USBPHY_CTRL_CLKGATE, x-io_priv + HW_USBPHY_CTRL_CLR); -- 1.7.8 -- 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 v6 14/15] usb: phy-mxs: Add system suspend/resume API
We need this to keep PHY's power on or off during the system suspend mode. If we need to enable USB wakeup, then we must keep PHY's power being on during the system suspend mode. Otherwise, we need to keep PHY's power being off to save power. Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/phy/phy-mxs-usb.c | 58 + 1 files changed, 58 insertions(+), 0 deletions(-) diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index 1bf78ee..885f8d9 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c @@ -57,6 +57,10 @@ #define BM_USBPHY_DEBUG_CLKGATEBIT(30) /* Anatop Registers */ +#define ANADIG_ANA_MISC0 0x150 +#define ANADIG_ANA_MISC0_SET 0x154 +#define ANADIG_ANA_MISC0_CLR 0x158 + #define ANADIG_USB1_VBUS_DET_STAT 0x1c0 #define ANADIG_USB2_VBUS_DET_STAT 0x220 @@ -65,6 +69,9 @@ #define ANADIG_USB2_LOOPBACK_SET 0x244 #define ANADIG_USB2_LOOPBACK_CLR 0x248 +#define BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG BIT(12) +#define BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG_SL BIT(11) + #define BM_ANADIG_USB1_VBUS_DET_STAT_VBUS_VALIDBIT(3) #define BM_ANADIG_USB2_VBUS_DET_STAT_VBUS_VALIDBIT(3) @@ -139,6 +146,16 @@ struct mxs_phy { int port_id; }; +static inline bool is_imx6q_phy(struct mxs_phy *mxs_phy) +{ + return mxs_phy-data == imx6q_phy_data; +} + +static inline bool is_imx6sl_phy(struct mxs_phy *mxs_phy) +{ + return mxs_phy-data == imx6sl_phy_data; +} + static int mxs_phy_hw_init(struct mxs_phy *mxs_phy) { int ret; @@ -244,6 +261,22 @@ static void mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool on) } +static void mxs_phy_enable_ldo_in_suspend(struct mxs_phy *mxs_phy, bool on) +{ + unsigned int reg = on ? ANADIG_ANA_MISC0_SET : ANADIG_ANA_MISC0_CLR; + + /* If the SoCs don't have anatop, quit */ + if (!mxs_phy-regmap_anatop) + return; + + if (is_imx6q_phy(mxs_phy)) + regmap_write(mxs_phy-regmap_anatop, reg, + BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG); + else if (is_imx6sl_phy(mxs_phy)) + regmap_write(mxs_phy-regmap_anatop, + reg, BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG_SL); +} + static int mxs_phy_init(struct usb_phy *phy) { struct mxs_phy *mxs_phy = to_mxs_phy(phy); @@ -435,6 +468,8 @@ static int mxs_phy_probe(struct platform_device *pdev) } } + device_set_wakeup_capable(pdev-dev, true); + ret = usb_add_phy_dev(mxs_phy-phy); if (ret) return ret; @@ -451,6 +486,28 @@ static int mxs_phy_remove(struct platform_device *pdev) return 0; } +static int mxs_phy_system_suspend(struct device *dev) +{ + struct mxs_phy *mxs_phy = dev_get_drvdata(dev); + + if (device_may_wakeup(dev)) + mxs_phy_enable_ldo_in_suspend(mxs_phy, true); + + return 0; +} + +static int mxs_phy_system_resume(struct device *dev) +{ + struct mxs_phy *mxs_phy = dev_get_drvdata(dev); + + if (device_may_wakeup(dev)) + mxs_phy_enable_ldo_in_suspend(mxs_phy, false); + + return 0; +} + +SIMPLE_DEV_PM_OPS(mxs_phy_pm, mxs_phy_system_suspend, mxs_phy_system_resume); + static struct platform_driver mxs_phy_driver = { .probe = mxs_phy_probe, .remove = mxs_phy_remove, @@ -458,6 +515,7 @@ static struct platform_driver mxs_phy_driver = { .name = DRIVER_NAME, .owner = THIS_MODULE, .of_match_table = mxs_phy_dt_ids, + .pm = mxs_phy_pm, }, }; -- 1.7.8 -- 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: host: xhci: Move suspend ops under PM_SLEEP to avoid warning
On Thursday 12 December 2013 08:51 PM, David Cohen wrote: On Thu, Dec 12, 2013 at 08:06:24PM -0500, Santosh Shilimkar wrote: Otherwise you get below build warnings drivers/usb/host/xhci-plat.c:201:12: warning: ‘xhci_plat_suspend’ defined but not used [-Wunused-function] drivers/usb/host/xhci-plat.c:209:12: warning: ‘xhci_plat_resume’ defined but not used [-Wunused-function] Cc: Sarah Sharp sarah.a.sh...@linux.intel.com Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Signed-off-by: Santosh Shilimkar santosh.shilim...@ti.com --- drivers/usb/host/xhci-plat.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index d9c169f..4875be5 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -197,7 +197,7 @@ static int xhci_plat_remove(struct platform_device *dev) return 0; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP Can't you just remove these #ifdefs altogether? xhci_plat_pm_ops is set using SET_SYSTEM_SLEEP_PM_OPS() macro which already handles '#ifdef CONFIG_PM_SLEEP' case. It does handle the difference but the hooks implemented would show-up un-used warning if you remove the #ifdefs. drivers/usb/host/xhci-plat.c:200:12: warning: ‘xhci_plat_suspend’ defined but not used [-Wunused-function] drivers/usb/host/xhci-plat.c:208:12: warning: ‘xhci_plat_resume’ defined but not used [-Wunused-function] So you need to wrap them under the PM_SLEEP check. Regards, Santosh -- 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: host: xhci: Move suspend ops under PM_SLEEP to avoid warning
On Thu, Dec 12, 2013 at 09:01:04PM -0500, Santosh Shilimkar wrote: On Thursday 12 December 2013 08:51 PM, David Cohen wrote: On Thu, Dec 12, 2013 at 08:06:24PM -0500, Santosh Shilimkar wrote: Otherwise you get below build warnings drivers/usb/host/xhci-plat.c:201:12: warning: ‘xhci_plat_suspend’ defined but not used [-Wunused-function] drivers/usb/host/xhci-plat.c:209:12: warning: ‘xhci_plat_resume’ defined but not used [-Wunused-function] Cc: Sarah Sharp sarah.a.sh...@linux.intel.com Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Signed-off-by: Santosh Shilimkar santosh.shilim...@ti.com --- drivers/usb/host/xhci-plat.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index d9c169f..4875be5 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -197,7 +197,7 @@ static int xhci_plat_remove(struct platform_device *dev) return 0; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP Can't you just remove these #ifdefs altogether? xhci_plat_pm_ops is set using SET_SYSTEM_SLEEP_PM_OPS() macro which already handles '#ifdef CONFIG_PM_SLEEP' case. It does handle the difference but the hooks implemented would show-up un-used warning if you remove the #ifdefs. drivers/usb/host/xhci-plat.c:200:12: warning: ‘xhci_plat_suspend’ defined but not used [-Wunused-function] drivers/usb/host/xhci-plat.c:208:12: warning: ‘xhci_plat_resume’ defined but not used [-Wunused-function] So you need to wrap them under the PM_SLEEP check. Yeah... it's not smart enought :) But you could still remove the #else condition and the ugly DEV_PM_OPS macro. Br, David Regards, Santosh -- 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/7] usb: dwc3: pci: add pm_runtime support
On Thu, Dec 12, 2013 at 05:56:05PM -0800, David Cohen wrote: On Thu, Dec 12, 2013 at 03:38:41PM -0600, Felipe Balbi wrote: teach the PCI glue about pm_runtime so that it's easier to teach dwc3 core about it later. No functional changes otherwise. Signed-off-by: Felipe Balbi ba...@ti.com I was able to test this one with Intel Merrifield: Acked-by: David Cohen david.a.co...@linux.intel.com cool, thanks. Although that'd be a Tested-by. Is it ok to add your name as Tested-by instead ? -- balbi signature.asc Description: Digital signature
Re: [PATCH v6 02/15] usb: phy-mxs: Add platform judgement code
On Fri, Dec 13, 2013 at 09:23:32AM +0800, Peter Chen wrote: The mxs-phy has several bugs and features at different versions, the driver code can get it through of_device_id.data. Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/phy/phy-mxs-usb.c | 58 ++-- 1 files changed, 49 insertions(+), 9 deletions(-) diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index 545844b..6d49040 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Freescale Semiconductor, Inc. + * Copyright 2012-2013 Freescale Semiconductor, Inc. * Copyright (C) 2012 Marek Vasut ma...@denx.de * on behalf of DENX Software Engineering GmbH * @@ -20,6 +20,7 @@ #include linux/delay.h #include linux/err.h #include linux/io.h +#include linux/of_device.h #define DRIVER_NAME mxs_phy @@ -34,13 +35,55 @@ #define BM_USBPHY_CTRL_ENUTMILEVEL2 BIT(14) #define BM_USBPHY_CTRL_ENHOSTDISCONDETECTBIT(1) +#define to_mxs_phy(p) container_of((p), struct mxs_phy, phy) defined, but never used. -- balbi signature.asc Description: Digital signature
Re: [PATCH v6 03/15] usb: phy-mxs: Add auto clock and power setting
On Fri, Dec 13, 2013 at 09:23:33AM +0800, Peter Chen wrote: With the auto setting, the PHY's clock and power can be recovered correctly from low power mode, it is ganranteed by IC logic. s/ganranteed/guaranteed Also, I think you need to be slightly more verbose here. Maybe explain a bit what is the auto setting. From what I can see from the code, it's a way to let HW manage clock gating. Another question, does this feature work in all SoCs where this IP is available ? cheers -- balbi signature.asc Description: Digital signature
Re: [PATCH 3/7] usb: dwc3: pci: add pm_runtime support
On Thu, Dec 12, 2013 at 10:17:19PM -0600, Felipe Balbi wrote: On Thu, Dec 12, 2013 at 05:56:05PM -0800, David Cohen wrote: On Thu, Dec 12, 2013 at 03:38:41PM -0600, Felipe Balbi wrote: teach the PCI glue about pm_runtime so that it's easier to teach dwc3 core about it later. No functional changes otherwise. Signed-off-by: Felipe Balbi ba...@ti.com I was able to test this one with Intel Merrifield: Acked-by: David Cohen david.a.co...@linux.intel.com cool, thanks. Although that'd be a Tested-by. Is it ok to add your name as Tested-by instead ? Yeah :) Br, David -- balbi -- 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 04/15] usb: doc: phy-mxs: update binding for adding anatop phandle
On Fri, Dec 13, 2013 at 09:23:34AM +0800, Peter Chen wrote: Add anatop phandle which is used to access anatop registers to control PHY's power and other USB operations. no related to this patch, but this feels like OMAP's System Control Module (a rather simplistic IP which control power for a few other IPs). We're starting to see a pattern here, eventually we will need a more generic approach to such types of modules. For now, don't worry :-) -- balbi signature.asc Description: Digital signature
Re: [PATCH v6 06/15] usb: phy-mxs: Add anatop regmap
Hi, On Fri, Dec 13, 2013 at 09:23:36AM +0800, Peter Chen wrote: @@ -226,6 +235,16 @@ static int mxs_phy_probe(struct platform_device *pdev) platform_set_drvdata(pdev, mxs_phy); + if (mxs_phy-data-flags MXS_PHY_HAS_ANATOP) { instead of the flag, you can check if that binding exist and use the binding itself as a flag. -- balbi signature.asc Description: Digital signature
Re: [PATCH v6 07/15] usb: phy: add notify suspend and resume callback
On Fri, Dec 13, 2013 at 09:23:37AM +0800, Peter Chen wrote: They are used to notify PHY that the controller enters suspend or finishes resume. Signed-off-by: Peter Chen peter.c...@freescale.com --- include/linux/usb/phy.h | 23 +++ 1 files changed, 23 insertions(+), 0 deletions(-) diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h index 6c0b1c5..a747960 100644 --- a/include/linux/usb/phy.h +++ b/include/linux/usb/phy.h @@ -116,6 +116,11 @@ struct usb_phy { enum usb_device_speed speed); int (*notify_disconnect)(struct usb_phy *x, enum usb_device_speed speed); + int (*notify_suspend)(struct usb_phy *x, + enum usb_device_speed speed); + int (*notify_resume)(struct usb_phy *x, + enum usb_device_speed speed); + I still don't think this is necessary. Why don't you just call usb_phy_set_suspend() directly ? And why do you need the extra speed argument ? -- balbi signature.asc Description: Digital signature
Re: [PATCH v6 08/15] usb: phy-mxs: Add implementation of nofity_suspend and notify_resume
On Fri, Dec 13, 2013 at 09:23:38AM +0800, Peter Chen wrote: Implementation of notify_suspend and notify_resume will be different according to mxs_phy_data-flags. Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/phy/phy-mxs-usb.c | 55 ++--- 1 files changed, 51 insertions(+), 4 deletions(-) diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index 0ef930a..e3df53f 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c @@ -166,8 +166,8 @@ static int mxs_phy_suspend(struct usb_phy *x, int suspend) static int mxs_phy_on_connect(struct usb_phy *phy, enum usb_device_speed speed) { - dev_dbg(phy-dev, %s speed device has connected\n, - (speed == USB_SPEED_HIGH) ? high : non-high); + dev_dbg(phy-dev, %s device has connected\n, + (speed == USB_SPEED_HIGH) ? HS : FS/LS); unrelated. @@ -179,8 +179,8 @@ static int mxs_phy_on_connect(struct usb_phy *phy, static int mxs_phy_on_disconnect(struct usb_phy *phy, enum usb_device_speed speed) { - dev_dbg(phy-dev, %s speed device has disconnected\n, - (speed == USB_SPEED_HIGH) ? high : non-high); + dev_dbg(phy-dev, %s device has disconnected\n, + (speed == USB_SPEED_HIGH) ? HS : FS/LS); unrelated. @@ -189,6 +189,48 @@ static int mxs_phy_on_disconnect(struct usb_phy *phy, return 0; } +static int mxs_phy_on_suspend(struct usb_phy *phy, + enum usb_device_speed speed) +{ + struct mxs_phy *mxs_phy = to_mxs_phy(phy); + + dev_dbg(phy-dev, %s device has suspended\n, + (speed == USB_SPEED_HIGH) ? HS : FS/LS); + + /* delay 4ms to wait bus entering idle */ + usleep_range(4000, 5000); + + if (mxs_phy-data-flags MXS_PHY_ABNORMAL_IN_SUSPEND) { + writel_relaxed(0x, phy-io_priv + HW_USBPHY_PWD); + writel_relaxed(0, phy-io_priv + HW_USBPHY_PWD); + } + + if (speed == USB_SPEED_HIGH) + writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT, + phy-io_priv + HW_USBPHY_CTRL_CLR); why only on HS ? So if !HS and !ABNORMAL, this is no-op. +static int mxs_phy_on_resume(struct usb_phy *phy, + enum usb_device_speed speed) +{ + dev_dbg(phy-dev, %s device has resumed\n, + (speed == USB_SPEED_HIGH) ? HS : FS/LS); + + if (speed == USB_SPEED_HIGH) { + /* Make sure the device has switched to High-Speed mode */ + udelay(500); + writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT, + phy-io_priv + HW_USBPHY_CTRL_SET); + } likewise, if !HS it's a no-op. @@ -235,6 +277,11 @@ static int mxs_phy_probe(struct platform_device *pdev) platform_set_drvdata(pdev, mxs_phy); + if (mxs_phy-data-flags MXS_PHY_SENDING_SOF_TOO_FAST) { + mxs_phy-phy.notify_suspend = mxs_phy_on_suspend; + mxs_phy-phy.notify_resume = mxs_phy_on_resume; + } hmm, and seems like you only need notify_* on a buggy device. Sorry Peter but you don't have enough arguments to make me agree with this (and previous) patch. You gotta find a better way to handle this using normal phy suspend/resume calls. -- balbi signature.asc Description: Digital signature
Re: [PATCH v6 15/15] usb: phy-mxs: Add sync time after controller clear phcd
On Fri, Dec 13, 2013 at 09:23:45AM +0800, Peter Chen wrote: After clear portsc.phcd, PHY needs 200us stable time for switch 32K clock to AHB clock. Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/phy/phy-mxs-usb.c | 11 +++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index 885f8d9..68bd981 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c @@ -156,6 +156,15 @@ static inline bool is_imx6sl_phy(struct mxs_phy *mxs_phy) return mxs_phy-data == imx6sl_phy_data; } +/* + * PHY needs some 32K cycles to switch from 32K clock to + * bus (such as AHB/AXI, etc) clock. + */ +static void mxs_phy_clock_switch_delay(void) +{ + usleep_range(300, 400); +} shouldn't this be handled by clk_set_parent() itself ? -- balbi signature.asc Description: Digital signature
RE: [PATCH 7/7] usb: dwc3: exynos: add pm_runtime support
Hi Felipe, -static int dwc3_exynos_suspend(struct device *dev) +static int __dwc3_exynos_suspend(struct dwc3_exynos *exynos) { - struct dwc3_exynos *exynos = dev_get_drvdata(dev); - clk_disable(exynos-clk); return 0; } +static int __dwc3_exynos_resume(struct dwc3_exynos *exynos) +{ + return clk_enable(exynos-clk); +} + +static int dwc3_exynos_suspend(struct device *dev) +{ + struct dwc3_exynos *exynos = dev_get_drvdata(dev); + + return __dwc3_exynos_suspend(exynos); If dwc3-exynos is runtime suspended, the clock will be disabled second time here (unbalanced clk_enable/clk_disable). +} + static int dwc3_exynos_resume(struct device *dev) { struct dwc3_exynos *exynos = dev_get_drvdata(dev); + int ret; - clk_enable(exynos-clk); + ret = __dwc3_exynos_resume(exynos); + if (ret) + return ret; /* runtime set active to reflect active state. */ pm_runtime_disable(dev); @@ -207,8 +238,24 @@ static int dwc3_exynos_resume(struct device *dev) return 0; } +static int dwc3_exynos_runtime_suspend(struct device *dev) +{ + struct dwc3_exynos *exynos = dev_get_drvdata(dev); + + return __dwc3_exynos_suspend(exynos); +} + +static int dwc3_exynos_runtime_resume(struct device *dev) +{ + struct dwc3_exynos *exynos = dev_get_drvdata(dev); + + return __dwc3_exynos_resume(exynos); +} 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
[RFC/PATCH 2/3] usb/xhci: implement proper static inline stubs when !CONFIG_PM
Current xhci_suspend() and xhci_resume() implementation in case of CONFIG_PM not defined is buggy. If we try to use them we get the following error: drivers/usb/host/xhci-plat.c: In function ‘xhci_plat_suspend’: drivers/usb/host/xhci-plat.c:205:21: error: called object ‘0u’ is not a function drivers/usb/host/xhci-plat.c: In function ‘xhci_plat_resume’: drivers/usb/host/xhci-plat.c:213:20: error: called object ‘0u’ is not a function It happens because the function names are replaced by NULL but the brackets stay: NULL() This patch implements proper static inline stubs. Signed-off-by: David Cohen david.a.co...@linux.intel.com --- drivers/usb/host/xhci.h | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 941d5f59e4dc..6a5e7a98de7e 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1771,8 +1771,10 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks); int xhci_suspend(struct xhci_hcd *xhci); int xhci_resume(struct xhci_hcd *xhci, bool hibernated); #else -#definexhci_suspendNULL -#definexhci_resume NULL +static inline int +xhci_suspend(struct xhci_hcd *xhci) { return 0; } +static inline int +xhci_resume(struct xhci_hcd *xhci, bool hibernated) { return 0; } #endif int xhci_get_frame(struct usb_hcd *hcd); -- 1.8.4.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
[RFC/PATCH 0/3] pm: Make SET_*_PM_OPS() macros more smart
Hi, These patches are proposal to extend the lack of #ifdef checks on PM callback to its implementation too. Currently SET_*_PM_OPS() macros make #ifdefs checks not necessary when setting the callback to PM ops, but the callbacks implementation don't see same benefit. This RFC Solves a problem reported by Santosh on xhci-plat.c driver due to wrong #ifdef checks: drivers/usb/host/xhci-plat.c:201:12: warning: ‘xhci_plat_suspend’ defined but not used [-Wunused-function] drivers/usb/host/xhci-plat.c:209:12: warning: ‘xhci_plat_resume’ defined but not used [-Wunused-function] But instead of fixing the #ifdefs, we remove the need for it :) Br, David Cohen --- David Cohen (2): pm: make PM macros more smart usb/xhci: implement proper static inline stubs when !CONFIG_PM Santosh Shilimkar (1): usb/xhci-plat: remove unnecessary #ifdef checks for CONFIG_PM_SLEEP drivers/usb/host/xhci-plat.c | 7 +-- drivers/usb/host/xhci.h | 6 -- include/linux/pm.h | 11 +-- 3 files changed, 14 insertions(+), 10 deletions(-) -- 1.8.4.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
[RFC/PATCH 1/3] pm: make PM macros more smart
This patch makes SET_SYSTEM_SLEEP_PM_OPS() and SET_RUNTIME_PM_OPS() more smart. Despite those macros check for '#ifdef CONFIG_PM_SLEEP/RUNTIME' to avoid setting the callbacks when such #ifdef's aren't defined, they don't handle compiler to avoid messages like that: drivers/usb/host/xhci-plat.c:200:12: warning: ‘xhci_plat_suspend’ defined but not used [-Wunused-function] drivers/usb/host/xhci-plat.c:208:12: warning: ‘xhci_plat_resume’ defined but not used [-Wunused-function] As result, those macros get rid of #ifdef's when setting callbacks but not when implementing them. With this patch, drivers using SET_*_PM_OPS() macros don't need to #ifdef the callbacks implementation as well. Signed-off-by: David Cohen david.a.co...@linux.intel.com --- include/linux/pm.h | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/linux/pm.h b/include/linux/pm.h index a224c7f5c377..41a0f3b42209 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -299,6 +299,8 @@ struct dev_pm_ops { int (*runtime_idle)(struct device *dev); }; +#define MAKE_ME_NULL(fn) ((void *)((unsigned long)(fn) - (unsigned long)(fn))) + #ifdef CONFIG_PM_SLEEP #define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ .suspend = suspend_fn, \ @@ -308,7 +310,9 @@ struct dev_pm_ops { .poweroff = suspend_fn, \ .restore = resume_fn, #else -#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) +#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ + .suspend = MAKE_ME_NULL(suspend_fn), \ + .resume = MAKE_ME_NULL(resume_fn), #endif #ifdef CONFIG_PM_RUNTIME @@ -317,7 +321,10 @@ struct dev_pm_ops { .runtime_resume = resume_fn, \ .runtime_idle = idle_fn, #else -#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) +#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \ + .runtime_suspend = MAKE_ME_NULL(suspend_fn), \ + .runtime_resume = MAKE_ME_NULL(resume_fn), \ + .runtime_idle = MAKE_ME_NULL(idle_fn), #endif /* -- 1.8.4.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] usb: host: xhci: Move suspend ops under PM_SLEEP to avoid warning
On Thu, Dec 12, 2013 at 07:25:55PM -0800, David Cohen wrote: On Thu, Dec 12, 2013 at 09:01:04PM -0500, Santosh Shilimkar wrote: On Thursday 12 December 2013 08:51 PM, David Cohen wrote: On Thu, Dec 12, 2013 at 08:06:24PM -0500, Santosh Shilimkar wrote: Otherwise you get below build warnings drivers/usb/host/xhci-plat.c:201:12: warning: ‘xhci_plat_suspend’ defined but not used [-Wunused-function] drivers/usb/host/xhci-plat.c:209:12: warning: ‘xhci_plat_resume’ defined but not used [-Wunused-function] Cc: Sarah Sharp sarah.a.sh...@linux.intel.com Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Signed-off-by: Santosh Shilimkar santosh.shilim...@ti.com --- drivers/usb/host/xhci-plat.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index d9c169f..4875be5 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -197,7 +197,7 @@ static int xhci_plat_remove(struct platform_device *dev) return 0; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP Can't you just remove these #ifdefs altogether? xhci_plat_pm_ops is set using SET_SYSTEM_SLEEP_PM_OPS() macro which already handles '#ifdef CONFIG_PM_SLEEP' case. It does handle the difference but the hooks implemented would show-up un-used warning if you remove the #ifdefs. drivers/usb/host/xhci-plat.c:200:12: warning: ‘xhci_plat_suspend’ defined but not used [-Wunused-function] drivers/usb/host/xhci-plat.c:208:12: warning: ‘xhci_plat_resume’ defined but not used [-Wunused-function] So you need to wrap them under the PM_SLEEP check. Yeah... it's not smart enought :) But you could still remove the #else condition and the ugly DEV_PM_OPS macro. Since this patch is not urgent, I sent a RFC proposing smarter SET_*_PM_OPS(). I included your patch (a bit different) here: https://patchwork.kernel.org/patch/3337961/ Br, David Br, David Regards, Santosh -- 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 -- 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 02/15] usb: phy-mxs: Add platform judgement code
On Thu, Dec 12, 2013 at 10:19:19PM -0600, Felipe Balbi wrote: On Fri, Dec 13, 2013 at 09:23:32AM +0800, Peter Chen wrote: The mxs-phy has several bugs and features at different versions, the driver code can get it through of_device_id.data. Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/phy/phy-mxs-usb.c | 58 ++-- 1 files changed, 49 insertions(+), 9 deletions(-) diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index 545844b..6d49040 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Freescale Semiconductor, Inc. + * Copyright 2012-2013 Freescale Semiconductor, Inc. * Copyright (C) 2012 Marek Vasut ma...@denx.de * on behalf of DENX Software Engineering GmbH * @@ -20,6 +20,7 @@ #include linux/delay.h #include linux/err.h #include linux/io.h +#include linux/of_device.h #define DRIVER_NAME mxs_phy @@ -34,13 +35,55 @@ #define BM_USBPHY_CTRL_ENUTMILEVEL2BIT(14) #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT BIT(1) +#define to_mxs_phy(p) container_of((p), struct mxs_phy, phy) defined, but never used. At current code, this define is after definition of struct mxs_phy, I think the lines of #define should be at the same place, so I move it up. -- Best Regards, Peter Chen -- 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 04/15] usb: doc: phy-mxs: update binding for adding anatop phandle
On Fri, Dec 13, 2013 at 12:25 PM, Felipe Balbi ba...@ti.com wrote: On Fri, Dec 13, 2013 at 09:23:34AM +0800, Peter Chen wrote: Add anatop phandle which is used to access anatop registers to control PHY's power and other USB operations. no related to this patch, but this feels like OMAP's System Control Module (a rather simplistic IP which control power for a few other IPs). We're starting to see a pattern here, eventually we will need a more generic approach to such types of modules. For now, don't worry :-) We use syscon (system controller) driver (drivers/mfd/syscon.c) to handle it, syscon uses regmap to visit register which can keep register access exclusively. -- BR, Peter Chen -- 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/15] usb: phy-mxs: Add anatop regmap
On Fri, Dec 13, 2013 at 12:26 PM, Felipe Balbi ba...@ti.com wrote: Hi, On Fri, Dec 13, 2013 at 09:23:36AM +0800, Peter Chen wrote: @@ -226,6 +235,16 @@ static int mxs_phy_probe(struct platform_device *pdev) platform_set_drvdata(pdev, mxs_phy); + if (mxs_phy-data-flags MXS_PHY_HAS_ANATOP) { instead of the flag, you can check if that binding exist and use the binding itself as a flag. If flag MXS_PHY_HAS_ANATOP is existed, that binding must need to be existed, or it is an error. syscon_regmap_lookup_by_phandle will return error is the binding is not existed. -- BR, Peter Chen -- 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 07/15] usb: phy: add notify suspend and resume callback
On Fri, Dec 13, 2013 at 12:27 PM, Felipe Balbi ba...@ti.com wrote: On Fri, Dec 13, 2013 at 09:23:37AM +0800, Peter Chen wrote: They are used to notify PHY that the controller enters suspend or finishes resume. Signed-off-by: Peter Chen peter.c...@freescale.com --- include/linux/usb/phy.h | 23 +++ 1 files changed, 23 insertions(+), 0 deletions(-) diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h index 6c0b1c5..a747960 100644 --- a/include/linux/usb/phy.h +++ b/include/linux/usb/phy.h @@ -116,6 +116,11 @@ struct usb_phy { enum usb_device_speed speed); int (*notify_disconnect)(struct usb_phy *x, enum usb_device_speed speed); + int (*notify_suspend)(struct usb_phy *x, + enum usb_device_speed speed); + int (*notify_resume)(struct usb_phy *x, + enum usb_device_speed speed); + I still don't think this is necessary. Why don't you just call usb_phy_set_suspend() directly ? And why do you need the extra speed argument ? -- It is different with PHY's power/clock. Eg, for .notify_resume, it needs to be called after host controller finishes sending resume signal. If its operation is executed before controller sends resume signal, the disconnect operation during the resume will not be detected. .notify_suspend and .notify_resume needs to be called during ehci suspend/ resume operation for mxs-phy typed controller. For mxs-phy, this operation is only needed for high speed connection, and to aligned with .nofity_connect/.notify_disconnect, I added the speed argument. If the user doesn't need it, it can pass USB_SPEED_UNKNOWN like below post. http://marc.info/?l=linux-usbm=138418998118519w=2 BR, Peter Chen -- 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 14/15] usb: phy-mxs: Add system suspend/resume API
On Fri, Dec 13, 2013 at 12:38 PM, Felipe Balbi ba...@ti.com wrote: On Fri, Dec 13, 2013 at 09:23:44AM +0800, Peter Chen wrote: +SIMPLE_DEV_PM_OPS(mxs_phy_pm, mxs_phy_system_suspend, mxs_phy_system_resume); should be static. Will change. -- BR, Peter Chen -- 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 01/15] usb: doc: phy-mxs: Add more compatible strings
Hi, Peter Chen wrote: Add fsl,imx6q-usbphy for imx6dq and imx6dl, add fsl,imx6sl-usbphy for imx6sl. Signed-off-by: Peter Chen peter.c...@freescale.com --- Documentation/devicetree/bindings/usb/mxs-phy.txt |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/mxs-phy.txt b/Documentation/devicetree/bindings/usb/mxs-phy.txt index 5835b27..d850e55 100644 --- a/Documentation/devicetree/bindings/usb/mxs-phy.txt +++ b/Documentation/devicetree/bindings/usb/mxs-phy.txt @@ -1,7 +1,8 @@ * Freescale MXS USB Phy Device Required properties: -- compatible: Should be fsl,imx23-usbphy +- compatible: fsl,imx23-usbphy for imx23 and imx28, fsl,imx6q-usbphy +for imx6dq and imx6dl, fsl,imx6sl-usbphy for imx6sl indentation? Lothar Waßmann -- ___ Ka-Ro electronics GmbH | Pascalstraße 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Geschäftsführer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | i...@karo-electronics.de ___ -- 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 01/15] usb: doc: phy-mxs: Add more compatible strings
On Fri, Dec 13, 2013 at 3:15 PM, Lothar Waßmann l...@karo-electronics.de wrote: Hi, Peter Chen wrote: Add fsl,imx6q-usbphy for imx6dq and imx6dl, add fsl,imx6sl-usbphy for imx6sl. Signed-off-by: Peter Chen peter.c...@freescale.com --- Documentation/devicetree/bindings/usb/mxs-phy.txt |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/mxs-phy.txt b/Documentation/devicetree/bindings/usb/mxs-phy.txt index 5835b27..d850e55 100644 --- a/Documentation/devicetree/bindings/usb/mxs-phy.txt +++ b/Documentation/devicetree/bindings/usb/mxs-phy.txt @@ -1,7 +1,8 @@ * Freescale MXS USB Phy Device Required properties: -- compatible: Should be fsl,imx23-usbphy +- compatible: fsl,imx23-usbphy for imx23 and imx28, fsl,imx6q-usbphy +for imx6dq and imx6dl, fsl,imx6sl-usbphy for imx6sl indentation? How many characters? 2 or 8? BR, Peter Chen -- 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: gadget: Add UDC driver for Aeroflex Gaisler GRUSBDC
On 2013-12-12 19:01, Felipe Balbi wrote: Hi, On Wed, Dec 04, 2013 at 09:13:58AM +0100, Andreas Larsson wrote: +static void gr_finish_request(struct gr_ep *ep, struct gr_request *req, + int status) +{ + struct gr_udc *dev; + + list_del_init(req-queue); + + if (likely(req-req.status == -EINPROGRESS)) + req-req.status = status; + else + status = req-req.status; + + dev = ep-dev; + usb_gadget_unmap_request(dev-gadget, req-req, ep-is_in); + gr_free_dma_desc_chain(dev, req); + + if (ep-is_in) /* For OUT, actual gets updated bit by bit */ + req-req.actual = req-req.length; + + if (!status) { + if (ep-is_in) + gr_dbgprint_request(SENT, ep, req); + else + gr_dbgprint_request(RECV, ep, req); + } + + /* Prevent changes to ep-queue during callback */ + ep-callback = 1; + if (req == dev-ep0reqo !status) { + if (req-setup) + gr_ep0_setup(dev, req); + else + dev_err(dev-dev, + Unexpected non setup packet on ep0in\n); + } else if (req-req.complete) { + unsigned long flags; + + /* +* Complete should be called with interrupts disabled according +* to the contract of struct usb_request +*/ + local_irq_save(flags); sorry but this driver isn't ready for inclusion. local_irq_save() is a pretty good hint that there's something wrong in the driver. Consider the fact that local_irq_save() will disable preemption even when CONFIG_PREEMPT_FULL is enabled and you have a bit a problem. This connection between local_irq_save and CONFIG_PREEMPT_RT_FULL was unknown to me. Sure, I can disable interrupts right at spin lock time. Also, the way you're using thread IRQs is quite wrong. I can't let that pass and get merged upstream, sorry. What is quite wrong? What is it that I need to fix? Best regards, Andreas Larsson -- 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