Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'xceiv-for-v3.7' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next

usb: xceiv: patches for v3.7 merge window

nop xceiv got its own header to avoid polluting otg.h. It has also
learned to work as USB2 and USB3 phys so we can use it on USB3
controllers.

Together with those two changes to nop xceiv, we're adding basic
PHY support to dwc3 driver, this is to allow platforms which actually
have a SW-controllable PHY talk to them through dwc3 driver.

We're adding a new phy driver for the OMAP architecture. This driver
is for the PHY found in OMAP4 SoCs, and a new phy driver for the
marvell architecture. An extra phy driver - for Tegra SoCs - is now
moving from arch/arm/mach-tegra* to drivers/usb/phy.

Also here, there's the creation of <linux/usb/phy.h> which should be
used from now on for PHY drivers, even those which don't support
OTG.

+1597 -603
+40
Documentation/devicetree/bindings/usb/twlxxxx-usb.txt
··· 1 + USB COMPARATOR OF TWL CHIPS 2 + 3 + TWL6030 USB COMPARATOR 4 + - compatible : Should be "ti,twl6030-usb" 5 + - interrupts : Two interrupt numbers to the cpu should be specified. First 6 + interrupt number is the otg interrupt number that raises ID interrupts when 7 + the controller has to act as host and the second interrupt number is the 8 + usb interrupt number that raises VBUS interrupts when the controller has to 9 + act as device 10 + - usb-supply : phandle to the regulator device tree node. It should be vusb 11 + if it is twl6030 or ldousb if it is twl6025 subclass. 12 + 13 + twl6030-usb { 14 + compatible = "ti,twl6030-usb"; 15 + interrupts = < 4 10 >; 16 + }; 17 + 18 + Board specific device node entry 19 + &twl6030-usb { 20 + usb-supply = <&vusb>; 21 + }; 22 + 23 + TWL4030 USB PHY AND COMPARATOR 24 + - compatible : Should be "ti,twl4030-usb" 25 + - interrupts : The interrupt numbers to the cpu should be specified. First 26 + interrupt number is the otg interrupt number that raises ID interrupts 27 + and VBUS interrupts. The second interrupt number is optional. 28 + - <supply-name>-supply : phandle to the regulator device tree node. 29 + <supply-name> should be vusb1v5, vusb1v8 and vusb3v1 30 + - usb_mode : The mode used by the phy to connect to the controller. "1" 31 + specifies "ULPI" mode and "2" specifies "CEA2011_3PIN" mode. 32 + 33 + twl4030-usb { 34 + compatible = "ti,twl4030-usb"; 35 + interrupts = < 10 4 >; 36 + usb1v5-supply = <&vusb1v5>; 37 + usb1v8-supply = <&vusb1v8>; 38 + usb3v1-supply = <&vusb3v1>; 39 + usb_mode = <1>; 40 + };
+17
Documentation/devicetree/bindings/usb/usb-phy.txt
··· 1 + USB PHY 2 + 3 + OMAP USB2 PHY 4 + 5 + Required properties: 6 + - compatible: Should be "ti,omap-usb2" 7 + - reg : Address and length of the register set for the device. Also 8 + add the address of control module dev conf register until a driver for 9 + control module is added 10 + 11 + This is usually a subnode of ocp2scp to which it is connected. 12 + 13 + usb2phy@4a0ad080 { 14 + compatible = "ti,omap-usb2"; 15 + reg = <0x4a0ad080 0x58>, 16 + <0x4a002300 0x4>; 17 + };
+1
arch/arm/mach-omap2/board-omap3evm.c
··· 32 32 #include <linux/spi/ads7846.h> 33 33 #include <linux/i2c/twl.h> 34 34 #include <linux/usb/otg.h> 35 + #include <linux/usb/nop-usb-xceiv.h> 35 36 #include <linux/smsc911x.h> 36 37 37 38 #include <linux/wl12xx.h>
-138
arch/arm/mach-omap2/omap_phy_internal.c
··· 31 31 #include <plat/usb.h> 32 32 #include "control.h" 33 33 34 - /* OMAP control module register for UTMI PHY */ 35 - #define CONTROL_DEV_CONF 0x300 36 - #define PHY_PD 0x1 37 - 38 - #define USBOTGHS_CONTROL 0x33c 39 - #define AVALID BIT(0) 40 - #define BVALID BIT(1) 41 - #define VBUSVALID BIT(2) 42 - #define SESSEND BIT(3) 43 - #define IDDIG BIT(4) 44 - 45 - static struct clk *phyclk, *clk48m, *clk32k; 46 - static void __iomem *ctrl_base; 47 - static int usbotghs_control; 48 - 49 - int omap4430_phy_init(struct device *dev) 50 - { 51 - ctrl_base = ioremap(OMAP443X_SCM_BASE, SZ_1K); 52 - if (!ctrl_base) { 53 - pr_err("control module ioremap failed\n"); 54 - return -ENOMEM; 55 - } 56 - /* Power down the phy */ 57 - __raw_writel(PHY_PD, ctrl_base + CONTROL_DEV_CONF); 58 - 59 - if (!dev) { 60 - iounmap(ctrl_base); 61 - return 0; 62 - } 63 - 64 - phyclk = clk_get(dev, "ocp2scp_usb_phy_ick"); 65 - if (IS_ERR(phyclk)) { 66 - dev_err(dev, "cannot clk_get ocp2scp_usb_phy_ick\n"); 67 - iounmap(ctrl_base); 68 - return PTR_ERR(phyclk); 69 - } 70 - 71 - clk48m = clk_get(dev, "ocp2scp_usb_phy_phy_48m"); 72 - if (IS_ERR(clk48m)) { 73 - dev_err(dev, "cannot clk_get ocp2scp_usb_phy_phy_48m\n"); 74 - clk_put(phyclk); 75 - iounmap(ctrl_base); 76 - return PTR_ERR(clk48m); 77 - } 78 - 79 - clk32k = clk_get(dev, "usb_phy_cm_clk32k"); 80 - if (IS_ERR(clk32k)) { 81 - dev_err(dev, "cannot clk_get usb_phy_cm_clk32k\n"); 82 - clk_put(phyclk); 83 - clk_put(clk48m); 84 - iounmap(ctrl_base); 85 - return PTR_ERR(clk32k); 86 - } 87 - return 0; 88 - } 89 - 90 - int omap4430_phy_set_clk(struct device *dev, int on) 91 - { 92 - static int state; 93 - 94 - if (on && !state) { 95 - /* Enable the phy clocks */ 96 - clk_enable(phyclk); 97 - clk_enable(clk48m); 98 - clk_enable(clk32k); 99 - state = 1; 100 - } else if (state) { 101 - /* Disable the phy clocks */ 102 - clk_disable(phyclk); 103 - clk_disable(clk48m); 104 - clk_disable(clk32k); 105 - state = 0; 106 - } 107 - return 0; 108 - } 109 - 110 - int omap4430_phy_power(struct device *dev, int ID, int on) 111 - { 112 - if (on) { 113 - if (ID) 114 - /* enable VBUS valid, IDDIG groung */ 115 - __raw_writel(AVALID | VBUSVALID, ctrl_base + 116 - USBOTGHS_CONTROL); 117 - else 118 - /* 119 - * Enable VBUS Valid, AValid and IDDIG 120 - * high impedance 121 - */ 122 - __raw_writel(IDDIG | AVALID | VBUSVALID, 123 - ctrl_base + USBOTGHS_CONTROL); 124 - } else { 125 - /* Enable session END and IDIG to high impedance. */ 126 - __raw_writel(SESSEND | IDDIG, ctrl_base + 127 - USBOTGHS_CONTROL); 128 - } 129 - return 0; 130 - } 131 - 132 - int omap4430_phy_suspend(struct device *dev, int suspend) 133 - { 134 - if (suspend) { 135 - /* Disable the clocks */ 136 - omap4430_phy_set_clk(dev, 0); 137 - /* Power down the phy */ 138 - __raw_writel(PHY_PD, ctrl_base + CONTROL_DEV_CONF); 139 - 140 - /* save the context */ 141 - usbotghs_control = __raw_readl(ctrl_base + USBOTGHS_CONTROL); 142 - } else { 143 - /* Enable the internel phy clcoks */ 144 - omap4430_phy_set_clk(dev, 1); 145 - /* power on the phy */ 146 - if (__raw_readl(ctrl_base + CONTROL_DEV_CONF) & PHY_PD) { 147 - __raw_writel(~PHY_PD, ctrl_base + CONTROL_DEV_CONF); 148 - mdelay(200); 149 - } 150 - 151 - /* restore the context */ 152 - __raw_writel(usbotghs_control, ctrl_base + USBOTGHS_CONTROL); 153 - } 154 - 155 - return 0; 156 - } 157 - 158 - int omap4430_phy_exit(struct device *dev) 159 - { 160 - if (ctrl_base) 161 - iounmap(ctrl_base); 162 - if (phyclk) 163 - clk_put(phyclk); 164 - if (clk48m) 165 - clk_put(clk48m); 166 - if (clk32k) 167 - clk_put(clk32k); 168 - 169 - return 0; 170 - } 171 - 172 34 void am35x_musb_reset(void) 173 35 { 174 36 u32 regval;
-5
arch/arm/mach-omap2/twl-common.c
··· 250 250 251 251 #if defined(CONFIG_ARCH_OMAP4) 252 252 static struct twl4030_usb_data omap4_usb_pdata = { 253 - .phy_init = omap4430_phy_init, 254 - .phy_exit = omap4430_phy_exit, 255 - .phy_power = omap4430_phy_power, 256 - .phy_set_clock = omap4430_phy_set_clk, 257 - .phy_suspend = omap4430_phy_suspend, 258 253 }; 259 254 260 255 static struct regulator_init_data omap4_vdac_idata = {
-3
arch/arm/mach-omap2/usb-musb.c
··· 117 117 dev->dma_mask = &musb_dmamask; 118 118 dev->coherent_dma_mask = musb_dmamask; 119 119 put_device(dev); 120 - 121 - if (cpu_is_omap44xx()) 122 - omap4430_phy_init(dev); 123 120 }
-1
arch/arm/mach-tegra/Makefile
··· 21 21 obj-$(CONFIG_TEGRA_SYSTEM_DMA) += dma.o 22 22 obj-$(CONFIG_CPU_FREQ) += cpu-tegra.o 23 23 obj-$(CONFIG_TEGRA_PCI) += pcie.o 24 - obj-$(CONFIG_USB_SUPPORT) += usb_phy.o 25 24 26 25 obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += board-dt-tegra20.o 27 26 obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += board-dt-tegra30.o
+1 -1
arch/arm/mach-tegra/devices.c
··· 27 27 #include <mach/irqs.h> 28 28 #include <mach/iomap.h> 29 29 #include <mach/dma.h> 30 - #include <mach/usb_phy.h> 30 + #include <linux/usb/tegra_usb_phy.h> 31 31 32 32 #include "gpio-names.h" 33 33 #include "devices.h"
+1 -1
arch/arm/mach-tegra/devices.h
··· 22 22 #include <linux/platform_device.h> 23 23 #include <linux/platform_data/tegra_usb.h> 24 24 25 - #include <mach/usb_phy.h> 25 + #include <linux/usb/tegra_usb_phy.h> 26 26 27 27 extern struct tegra_ulpi_config tegra_ehci2_ulpi_phy_config; 28 28
+5 -11
arch/arm/mach-tegra/include/mach/usb_phy.h include/linux/usb/tegra_usb_phy.h
··· 1 1 /* 2 - * arch/arm/mach-tegra/include/mach/usb_phy.h 3 - * 4 2 * Copyright (C) 2010 Google, Inc. 5 3 * 6 4 * This software is licensed under the terms of the GNU General Public ··· 12 14 * 13 15 */ 14 16 15 - #ifndef __MACH_USB_PHY_H 16 - #define __MACH_USB_PHY_H 17 + #ifndef __TEGRA_USB_PHY_H 18 + #define __TEGRA_USB_PHY_H 17 19 18 20 #include <linux/clk.h> 19 21 #include <linux/usb/otg.h> ··· 57 59 enum tegra_usb_phy_mode mode; 58 60 void *config; 59 61 struct usb_phy *ulpi; 62 + struct usb_phy u_phy; 63 + struct device *dev; 60 64 }; 61 65 62 66 struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance, 63 67 void __iomem *regs, void *config, enum tegra_usb_phy_mode phy_mode); 64 68 65 - int tegra_usb_phy_power_on(struct tegra_usb_phy *phy); 66 - 67 69 void tegra_usb_phy_clk_disable(struct tegra_usb_phy *phy); 68 70 69 71 void tegra_usb_phy_clk_enable(struct tegra_usb_phy *phy); 70 - 71 - void tegra_usb_phy_power_off(struct tegra_usb_phy *phy); 72 72 73 73 void tegra_usb_phy_preresume(struct tegra_usb_phy *phy); 74 74 ··· 77 81 78 82 void tegra_ehci_phy_restore_end(struct tegra_usb_phy *phy); 79 83 80 - void tegra_usb_phy_close(struct tegra_usb_phy *phy); 81 - 82 - #endif /* __MACH_USB_PHY_H */ 84 + #endif /* __TEGRA_USB_PHY_H */
+87 -65
arch/arm/mach-tegra/usb_phy.c drivers/usb/phy/tegra_usb_phy.c
··· 1 1 /* 2 - * arch/arm/mach-tegra/usb_phy.c 3 - * 4 2 * Copyright (C) 2010 Google, Inc. 5 3 * 6 4 * Author: ··· 29 31 #include <linux/usb/ulpi.h> 30 32 #include <asm/mach-types.h> 31 33 #include <mach/gpio-tegra.h> 32 - #include <mach/usb_phy.h> 34 + #include <linux/usb/tegra_usb_phy.h> 33 35 #include <mach/iomap.h> 34 36 35 37 #define ULPI_VIEWPORT 0x170 ··· 480 482 return 0; 481 483 } 482 484 483 - static void utmi_phy_power_off(struct tegra_usb_phy *phy) 485 + static int utmi_phy_power_off(struct tegra_usb_phy *phy) 484 486 { 485 487 unsigned long val; 486 488 void __iomem *base = phy->regs; ··· 512 514 UTMIP_FORCE_PDDR_POWERDOWN; 513 515 writel(val, base + UTMIP_XCVR_CFG1); 514 516 515 - utmip_pad_power_off(phy); 517 + return utmip_pad_power_off(phy); 516 518 } 517 519 518 520 static void utmi_phy_preresume(struct tegra_usb_phy *phy) ··· 636 638 return 0; 637 639 } 638 640 639 - static void ulpi_phy_power_off(struct tegra_usb_phy *phy) 641 + static int ulpi_phy_power_off(struct tegra_usb_phy *phy) 640 642 { 641 643 unsigned long val; 642 644 void __iomem *base = phy->regs; ··· 649 651 val &= ~(USB_PORTSC1_WKOC | USB_PORTSC1_WKDS | USB_PORTSC1_WKCN); 650 652 writel(val, base + USB_PORTSC1); 651 653 652 - gpio_direction_output(config->reset_gpio, 0); 653 654 clk_disable(phy->clk); 655 + return gpio_direction_output(config->reset_gpio, 0); 656 + } 657 + 658 + static int tegra_phy_init(struct usb_phy *x) 659 + { 660 + struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy); 661 + struct tegra_ulpi_config *ulpi_config; 662 + int err; 663 + 664 + if (phy_is_ulpi(phy)) { 665 + ulpi_config = phy->config; 666 + phy->clk = clk_get_sys(NULL, ulpi_config->clk); 667 + if (IS_ERR(phy->clk)) { 668 + pr_err("%s: can't get ulpi clock\n", __func__); 669 + err = -ENXIO; 670 + goto err1; 671 + } 672 + if (!gpio_is_valid(ulpi_config->reset_gpio)) 673 + ulpi_config->reset_gpio = 674 + of_get_named_gpio(phy->dev->of_node, 675 + "nvidia,phy-reset-gpio", 0); 676 + if (!gpio_is_valid(ulpi_config->reset_gpio)) { 677 + pr_err("%s: invalid reset gpio: %d\n", __func__, 678 + ulpi_config->reset_gpio); 679 + err = -EINVAL; 680 + goto err1; 681 + } 682 + gpio_request(ulpi_config->reset_gpio, "ulpi_phy_reset_b"); 683 + gpio_direction_output(ulpi_config->reset_gpio, 0); 684 + phy->ulpi = otg_ulpi_create(&ulpi_viewport_access_ops, 0); 685 + phy->ulpi->io_priv = phy->regs + ULPI_VIEWPORT; 686 + } else { 687 + err = utmip_pad_open(phy); 688 + if (err < 0) 689 + goto err1; 690 + } 691 + return 0; 692 + err1: 693 + clk_disable_unprepare(phy->pll_u); 694 + clk_put(phy->pll_u); 695 + return err; 696 + } 697 + 698 + static void tegra_usb_phy_close(struct usb_phy *x) 699 + { 700 + struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy); 701 + 702 + if (phy_is_ulpi(phy)) 703 + clk_put(phy->clk); 704 + else 705 + utmip_pad_close(phy); 706 + clk_disable_unprepare(phy->pll_u); 707 + clk_put(phy->pll_u); 708 + kfree(phy); 709 + } 710 + 711 + static int tegra_usb_phy_power_on(struct tegra_usb_phy *phy) 712 + { 713 + if (phy_is_ulpi(phy)) 714 + return ulpi_phy_power_on(phy); 715 + else 716 + return utmi_phy_power_on(phy); 717 + } 718 + 719 + static int tegra_usb_phy_power_off(struct tegra_usb_phy *phy) 720 + { 721 + if (phy_is_ulpi(phy)) 722 + return ulpi_phy_power_off(phy); 723 + else 724 + return utmi_phy_power_off(phy); 725 + } 726 + 727 + static int tegra_usb_phy_suspend(struct usb_phy *x, int suspend) 728 + { 729 + struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy); 730 + if (suspend) 731 + return tegra_usb_phy_power_off(phy); 732 + else 733 + return tegra_usb_phy_power_on(phy); 654 734 } 655 735 656 736 struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance, 657 737 void __iomem *regs, void *config, enum tegra_usb_phy_mode phy_mode) 658 738 { 659 739 struct tegra_usb_phy *phy; 660 - struct tegra_ulpi_config *ulpi_config; 661 740 unsigned long parent_rate; 662 741 int i; 663 742 int err; ··· 747 672 phy->regs = regs; 748 673 phy->config = config; 749 674 phy->mode = phy_mode; 675 + phy->dev = dev; 750 676 751 677 if (!phy->config) { 752 678 if (phy_is_ulpi(phy)) { ··· 780 704 goto err1; 781 705 } 782 706 783 - if (phy_is_ulpi(phy)) { 784 - ulpi_config = config; 785 - phy->clk = clk_get_sys(NULL, ulpi_config->clk); 786 - if (IS_ERR(phy->clk)) { 787 - pr_err("%s: can't get ulpi clock\n", __func__); 788 - err = -ENXIO; 789 - goto err1; 790 - } 791 - if (!gpio_is_valid(ulpi_config->reset_gpio)) 792 - ulpi_config->reset_gpio = 793 - of_get_named_gpio(dev->of_node, 794 - "nvidia,phy-reset-gpio", 0); 795 - if (!gpio_is_valid(ulpi_config->reset_gpio)) { 796 - pr_err("%s: invalid reset gpio: %d\n", __func__, 797 - ulpi_config->reset_gpio); 798 - err = -EINVAL; 799 - goto err1; 800 - } 801 - gpio_request(ulpi_config->reset_gpio, "ulpi_phy_reset_b"); 802 - gpio_direction_output(ulpi_config->reset_gpio, 0); 803 - phy->ulpi = otg_ulpi_create(&ulpi_viewport_access_ops, 0); 804 - phy->ulpi->io_priv = regs + ULPI_VIEWPORT; 805 - } else { 806 - err = utmip_pad_open(phy); 807 - if (err < 0) 808 - goto err1; 809 - } 707 + phy->u_phy.init = tegra_phy_init; 708 + phy->u_phy.shutdown = tegra_usb_phy_close; 709 + phy->u_phy.set_suspend = tegra_usb_phy_suspend; 810 710 811 711 return phy; 812 712 ··· 794 742 return ERR_PTR(err); 795 743 } 796 744 EXPORT_SYMBOL_GPL(tegra_usb_phy_open); 797 - 798 - int tegra_usb_phy_power_on(struct tegra_usb_phy *phy) 799 - { 800 - if (phy_is_ulpi(phy)) 801 - return ulpi_phy_power_on(phy); 802 - else 803 - return utmi_phy_power_on(phy); 804 - } 805 - EXPORT_SYMBOL_GPL(tegra_usb_phy_power_on); 806 - 807 - void tegra_usb_phy_power_off(struct tegra_usb_phy *phy) 808 - { 809 - if (phy_is_ulpi(phy)) 810 - ulpi_phy_power_off(phy); 811 - else 812 - utmi_phy_power_off(phy); 813 - } 814 - EXPORT_SYMBOL_GPL(tegra_usb_phy_power_off); 815 745 816 746 void tegra_usb_phy_preresume(struct tegra_usb_phy *phy) 817 747 { ··· 837 803 utmi_phy_clk_enable(phy); 838 804 } 839 805 EXPORT_SYMBOL_GPL(tegra_usb_phy_clk_enable); 840 - 841 - void tegra_usb_phy_close(struct tegra_usb_phy *phy) 842 - { 843 - if (phy_is_ulpi(phy)) 844 - clk_put(phy->clk); 845 - else 846 - utmip_pad_close(phy); 847 - clk_disable_unprepare(phy->pll_u); 848 - clk_put(phy->pll_u); 849 - kfree(phy); 850 - } 851 - EXPORT_SYMBOL_GPL(tegra_usb_phy_close);
+15
drivers/usb/dwc3/core.c
··· 50 50 #include <linux/dma-mapping.h> 51 51 #include <linux/of.h> 52 52 53 + #include <linux/usb/otg.h> 53 54 #include <linux/usb/ch9.h> 54 55 #include <linux/usb/gadget.h> 55 56 ··· 137 136 reg |= DWC3_GUSB2PHYCFG_PHYSOFTRST; 138 137 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); 139 138 139 + usb_phy_init(dwc->usb2_phy); 140 + usb_phy_init(dwc->usb3_phy); 140 141 mdelay(100); 141 142 142 143 /* Clear USB3 PHY reset */ ··· 466 463 if (!regs) { 467 464 dev_err(dev, "ioremap failed\n"); 468 465 return -ENOMEM; 466 + } 467 + 468 + dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); 469 + if (IS_ERR_OR_NULL(dwc->usb2_phy)) { 470 + dev_err(dev, "no usb2 phy configured\n"); 471 + return -EPROBE_DEFER; 472 + } 473 + 474 + dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3); 475 + if (IS_ERR_OR_NULL(dwc->usb3_phy)) { 476 + dev_err(dev, "no usb3 phy configured\n"); 477 + return -EPROBE_DEFER; 469 478 } 470 479 471 480 spin_lock_init(&dwc->lock);
+5
drivers/usb/dwc3/core.h
··· 624 624 * @maximum_speed: maximum speed requested (mainly for testing purposes) 625 625 * @revision: revision register contents 626 626 * @mode: mode of operation 627 + * @usb2_phy: pointer to USB2 PHY 628 + * @usb3_phy: pointer to USB3 PHY 627 629 * @is_selfpowered: true when we are selfpowered 628 630 * @three_stage_setup: set if we perform a three phase setup 629 631 * @ep0_bounced: true when we used bounce buffer ··· 668 666 669 667 struct usb_gadget gadget; 670 668 struct usb_gadget_driver *gadget_driver; 669 + 670 + struct usb_phy *usb2_phy; 671 + struct usb_phy *usb3_phy; 671 672 672 673 void __iomem *regs; 673 674 size_t regs_size;
+66
drivers/usb/dwc3/dwc3-exynos.c
··· 19 19 #include <linux/platform_data/dwc3-exynos.h> 20 20 #include <linux/dma-mapping.h> 21 21 #include <linux/clk.h> 22 + #include <linux/usb/otg.h> 23 + #include <linux/usb/nop-usb-xceiv.h> 22 24 23 25 #include "core.h" 24 26 25 27 struct dwc3_exynos { 26 28 struct platform_device *dwc3; 29 + struct platform_device *usb2_phy; 30 + struct platform_device *usb3_phy; 27 31 struct device *dev; 28 32 29 33 struct clk *clk; 30 34 }; 35 + 36 + static int __devinit dwc3_exynos_register_phys(struct dwc3_exynos *exynos) 37 + { 38 + struct nop_usb_xceiv_platform_data pdata; 39 + struct platform_device *pdev; 40 + int ret; 41 + 42 + memset(&pdata, 0x00, sizeof(pdata)); 43 + 44 + pdev = platform_device_alloc("nop_usb_xceiv", 0); 45 + if (!pdev) 46 + return -ENOMEM; 47 + 48 + exynos->usb2_phy = pdev; 49 + pdata.type = USB_PHY_TYPE_USB2; 50 + 51 + ret = platform_device_add_data(exynos->usb2_phy, &pdata, sizeof(pdata)); 52 + if (ret) 53 + goto err1; 54 + 55 + pdev = platform_device_alloc("nop_usb_xceiv", 1); 56 + if (!pdev) { 57 + ret = -ENOMEM; 58 + goto err1; 59 + } 60 + 61 + exynos->usb3_phy = pdev; 62 + pdata.type = USB_PHY_TYPE_USB3; 63 + 64 + ret = platform_device_add_data(exynos->usb3_phy, &pdata, sizeof(pdata)); 65 + if (ret) 66 + goto err2; 67 + 68 + ret = platform_device_add(exynos->usb2_phy); 69 + if (ret) 70 + goto err2; 71 + 72 + ret = platform_device_add(exynos->usb3_phy); 73 + if (ret) 74 + goto err3; 75 + 76 + return 0; 77 + 78 + err3: 79 + platform_device_del(exynos->usb2_phy); 80 + 81 + err2: 82 + platform_device_put(exynos->usb3_phy); 83 + 84 + err1: 85 + platform_device_put(exynos->usb2_phy); 86 + 87 + return ret; 88 + } 31 89 32 90 static int __devinit dwc3_exynos_probe(struct platform_device *pdev) 33 91 { ··· 108 50 devid = dwc3_get_device_id(); 109 51 if (devid < 0) 110 52 goto err1; 53 + 54 + ret = dwc3_exynos_register_phys(exynos); 55 + if (ret) { 56 + dev_err(&pdev->dev, "couldn't register PHYs\n"); 57 + goto err1; 58 + } 111 59 112 60 dwc3 = platform_device_alloc("dwc3", devid); 113 61 if (!dwc3) { ··· 184 120 struct dwc3_exynos_data *pdata = pdev->dev.platform_data; 185 121 186 122 platform_device_unregister(exynos->dwc3); 123 + platform_device_unregister(exynos->usb2_phy); 124 + platform_device_unregister(exynos->usb3_phy); 187 125 188 126 dwc3_put_device_id(exynos->dwc3->id); 189 127
+66
drivers/usb/dwc3/dwc3-omap.c
··· 48 48 #include <linux/io.h> 49 49 #include <linux/of.h> 50 50 51 + #include <linux/usb/otg.h> 52 + #include <linux/usb/nop-usb-xceiv.h> 53 + 51 54 #include "core.h" 52 55 53 56 /* ··· 134 131 spinlock_t lock; 135 132 136 133 struct platform_device *dwc3; 134 + struct platform_device *usb2_phy; 135 + struct platform_device *usb3_phy; 137 136 struct device *dev; 138 137 139 138 int irq; ··· 157 152 writel(value, base + offset); 158 153 } 159 154 155 + static int __devinit dwc3_omap_register_phys(struct dwc3_omap *omap) 156 + { 157 + struct nop_usb_xceiv_platform_data pdata; 158 + struct platform_device *pdev; 159 + int ret; 160 + 161 + memset(&pdata, 0x00, sizeof(pdata)); 162 + 163 + pdev = platform_device_alloc("nop_usb_xceiv", 0); 164 + if (!pdev) 165 + return -ENOMEM; 166 + 167 + omap->usb2_phy = pdev; 168 + pdata.type = USB_PHY_TYPE_USB2; 169 + 170 + ret = platform_device_add_data(omap->usb2_phy, &pdata, sizeof(pdata)); 171 + if (ret) 172 + goto err1; 173 + 174 + pdev = platform_device_alloc("nop_usb_xceiv", 1); 175 + if (!pdev) { 176 + ret = -ENOMEM; 177 + goto err1; 178 + } 179 + 180 + omap->usb3_phy = pdev; 181 + pdata.type = USB_PHY_TYPE_USB3; 182 + 183 + ret = platform_device_add_data(omap->usb3_phy, &pdata, sizeof(pdata)); 184 + if (ret) 185 + goto err2; 186 + 187 + ret = platform_device_add(omap->usb2_phy); 188 + if (ret) 189 + goto err2; 190 + 191 + ret = platform_device_add(omap->usb3_phy); 192 + if (ret) 193 + goto err3; 194 + 195 + return 0; 196 + 197 + err3: 198 + platform_device_del(omap->usb2_phy); 199 + 200 + err2: 201 + platform_device_put(omap->usb3_phy); 202 + 203 + err1: 204 + platform_device_put(omap->usb2_phy); 205 + 206 + return ret; 207 + } 160 208 161 209 static irqreturn_t dwc3_omap_interrupt(int irq, void *_omap) 162 210 { ··· 307 249 if (!base) { 308 250 dev_err(dev, "ioremap failed\n"); 309 251 return -ENOMEM; 252 + } 253 + 254 + ret = dwc3_omap_register_phys(omap); 255 + if (ret) { 256 + dev_err(dev, "couldn't register PHYs\n"); 257 + return ret; 310 258 } 311 259 312 260 devid = dwc3_get_device_id(); ··· 435 371 struct dwc3_omap *omap = platform_get_drvdata(pdev); 436 372 437 373 platform_device_unregister(omap->dwc3); 374 + platform_device_unregister(omap->usb2_phy); 375 + platform_device_unregister(omap->usb3_phy); 438 376 439 377 dwc3_put_device_id(omap->dwc3->id); 440 378
+67
drivers/usb/dwc3/dwc3-pci.c
··· 42 42 #include <linux/pci.h> 43 43 #include <linux/platform_device.h> 44 44 45 + #include <linux/usb/otg.h> 46 + #include <linux/usb/nop-usb-xceiv.h> 47 + 45 48 #include "core.h" 46 49 47 50 /* FIXME define these in <linux/pci_ids.h> */ ··· 54 51 struct dwc3_pci { 55 52 struct device *dev; 56 53 struct platform_device *dwc3; 54 + struct platform_device *usb2_phy; 55 + struct platform_device *usb3_phy; 57 56 }; 57 + 58 + static int __devinit dwc3_pci_register_phys(struct dwc3_pci *glue) 59 + { 60 + struct nop_usb_xceiv_platform_data pdata; 61 + struct platform_device *pdev; 62 + int ret; 63 + 64 + memset(&pdata, 0x00, sizeof(pdata)); 65 + 66 + pdev = platform_device_alloc("nop_usb_xceiv", 0); 67 + if (!pdev) 68 + return -ENOMEM; 69 + 70 + glue->usb2_phy = pdev; 71 + pdata.type = USB_PHY_TYPE_USB2; 72 + 73 + ret = platform_device_add_data(glue->usb2_phy, &pdata, sizeof(pdata)); 74 + if (ret) 75 + goto err1; 76 + 77 + pdev = platform_device_alloc("nop_usb_xceiv", 1); 78 + if (!pdev) { 79 + ret = -ENOMEM; 80 + goto err1; 81 + } 82 + 83 + glue->usb3_phy = pdev; 84 + pdata.type = USB_PHY_TYPE_USB3; 85 + 86 + ret = platform_device_add_data(glue->usb3_phy, &pdata, sizeof(pdata)); 87 + if (ret) 88 + goto err2; 89 + 90 + ret = platform_device_add(glue->usb2_phy); 91 + if (ret) 92 + goto err2; 93 + 94 + ret = platform_device_add(glue->usb3_phy); 95 + if (ret) 96 + goto err3; 97 + 98 + return 0; 99 + 100 + err3: 101 + platform_device_del(glue->usb2_phy); 102 + 103 + err2: 104 + platform_device_put(glue->usb3_phy); 105 + 106 + err1: 107 + platform_device_put(glue->usb2_phy); 108 + 109 + return ret; 110 + } 58 111 59 112 static int __devinit dwc3_pci_probe(struct pci_dev *pci, 60 113 const struct pci_device_id *id) ··· 138 79 139 80 pci_set_power_state(pci, PCI_D0); 140 81 pci_set_master(pci); 82 + 83 + ret = dwc3_pci_register_phys(glue); 84 + if (ret) { 85 + dev_err(dev, "couldn't register PHYs\n"); 86 + return ret; 87 + } 141 88 142 89 devid = dwc3_get_device_id(); 143 90 if (devid < 0) { ··· 209 144 { 210 145 struct dwc3_pci *glue = pci_get_drvdata(pci); 211 146 147 + platform_device_unregister(glue->usb2_phy); 148 + platform_device_unregister(glue->usb3_phy); 212 149 dwc3_put_device_id(glue->dwc3->id); 213 150 platform_device_unregister(glue->dwc3); 214 151 pci_set_drvdata(pci, NULL);
+9 -8
drivers/usb/host/ehci-tegra.c
··· 27 27 #include <linux/of_gpio.h> 28 28 #include <linux/pm_runtime.h> 29 29 30 - #include <mach/usb_phy.h> 30 + #include <linux/usb/tegra_usb_phy.h> 31 31 #include <mach/iomap.h> 32 32 33 33 #define TEGRA_USB_DMA_ALIGN 32 ··· 49 49 50 50 clk_prepare_enable(tegra->emc_clk); 51 51 clk_prepare_enable(tegra->clk); 52 - tegra_usb_phy_power_on(tegra->phy); 52 + usb_phy_set_suspend(&tegra->phy->u_phy, 0); 53 53 tegra->host_resumed = 1; 54 54 } 55 55 ··· 58 58 struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller); 59 59 60 60 tegra->host_resumed = 0; 61 - tegra_usb_phy_power_off(tegra->phy); 61 + usb_phy_set_suspend(&tegra->phy->u_phy, 1); 62 62 clk_disable_unprepare(tegra->clk); 63 63 clk_disable_unprepare(tegra->emc_clk); 64 64 } ··· 715 715 goto fail_io; 716 716 } 717 717 718 - err = tegra_usb_phy_power_on(tegra->phy); 718 + usb_phy_init(&tegra->phy->u_phy); 719 + 720 + err = usb_phy_set_suspend(&tegra->phy->u_phy, 0); 719 721 if (err) { 720 722 dev_err(&pdev->dev, "Failed to power on the phy\n"); 721 723 goto fail; ··· 763 761 if (!IS_ERR_OR_NULL(tegra->transceiver)) 764 762 otg_set_host(tegra->transceiver->otg, NULL); 765 763 #endif 766 - tegra_usb_phy_close(tegra->phy); 764 + usb_phy_shutdown(&tegra->phy->u_phy); 767 765 fail_io: 768 766 clk_disable_unprepare(tegra->emc_clk); 769 767 fail_emc_clk: ··· 791 789 #endif 792 790 793 791 usb_remove_hcd(hcd); 794 - 795 - tegra_usb_phy_close(tegra->phy); 796 - 797 792 usb_put_hcd(hcd); 793 + 794 + usb_phy_shutdown(&tegra->phy->u_phy); 798 795 799 796 clk_disable_unprepare(tegra->clk); 800 797
+1
drivers/usb/musb/am35x.c
··· 33 33 #include <linux/io.h> 34 34 #include <linux/platform_device.h> 35 35 #include <linux/dma-mapping.h> 36 + #include <linux/usb/nop-usb-xceiv.h> 36 37 37 38 #include <plat/usb.h> 38 39
+1
drivers/usb/musb/blackfin.c
··· 19 19 #include <linux/platform_device.h> 20 20 #include <linux/dma-mapping.h> 21 21 #include <linux/prefetch.h> 22 + #include <linux/usb/nop-usb-xceiv.h> 22 23 23 24 #include <asm/cacheflush.h> 24 25
+1
drivers/usb/musb/da8xx.c
··· 33 33 #include <linux/io.h> 34 34 #include <linux/platform_device.h> 35 35 #include <linux/dma-mapping.h> 36 + #include <linux/usb/nop-usb-xceiv.h> 36 37 37 38 #include <mach/da8xx.h> 38 39 #include <mach/usb.h>
+1
drivers/usb/musb/davinci.c
··· 33 33 #include <linux/gpio.h> 34 34 #include <linux/platform_device.h> 35 35 #include <linux/dma-mapping.h> 36 + #include <linux/usb/nop-usb-xceiv.h> 36 37 37 38 #include <mach/cputype.h> 38 39 #include <mach/hardware.h>
+1
drivers/usb/musb/musb_dsps.c
··· 36 36 #include <linux/dma-mapping.h> 37 37 #include <linux/pm_runtime.h> 38 38 #include <linux/module.h> 39 + #include <linux/usb/nop-usb-xceiv.h> 39 40 40 41 #include <linux/of.h> 41 42 #include <linux/of_device.h>
+1
drivers/usb/musb/tusb6010.c
··· 24 24 #include <linux/irq.h> 25 25 #include <linux/platform_device.h> 26 26 #include <linux/dma-mapping.h> 27 + #include <linux/usb/nop-usb-xceiv.h> 27 28 28 29 #include "musb_core.h" 29 30
+1 -1
drivers/usb/otg/Kconfig
··· 68 68 69 69 config TWL6030_USB 70 70 tristate "TWL6030 USB Transceiver Driver" 71 - depends on TWL4030_CORE 71 + depends on TWL4030_CORE && OMAP_USB2 72 72 select USB_OTG_UTILS 73 73 help 74 74 Enable this to support the USB OTG transceiver on TWL6030
+24 -10
drivers/usb/otg/fsl_otg.c
··· 544 544 */ 545 545 static int fsl_otg_set_host(struct usb_otg *otg, struct usb_bus *host) 546 546 { 547 - struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); 547 + struct fsl_otg *otg_dev; 548 548 549 - if (!otg || otg_dev != fsl_otg_dev) 549 + if (!otg) 550 + return -ENODEV; 551 + 552 + otg_dev = container_of(otg->phy, struct fsl_otg, phy); 553 + if (otg_dev != fsl_otg_dev) 550 554 return -ENODEV; 551 555 552 556 otg->host = host; ··· 594 590 static int fsl_otg_set_peripheral(struct usb_otg *otg, 595 591 struct usb_gadget *gadget) 596 592 { 597 - struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); 593 + struct fsl_otg *otg_dev; 598 594 595 + if (!otg) 596 + return -ENODEV; 597 + 598 + otg_dev = container_of(otg->phy, struct fsl_otg, phy); 599 599 VDBG("otg_dev 0x%x\n", (int)otg_dev); 600 600 VDBG("fsl_otg_dev 0x%x\n", (int)fsl_otg_dev); 601 - 602 - if (!otg || otg_dev != fsl_otg_dev) 601 + if (otg_dev != fsl_otg_dev) 603 602 return -ENODEV; 604 603 605 604 if (!gadget) { ··· 667 660 /* B-device start SRP */ 668 661 static int fsl_otg_start_srp(struct usb_otg *otg) 669 662 { 670 - struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); 663 + struct fsl_otg *otg_dev; 671 664 672 - if (!otg || otg_dev != fsl_otg_dev 673 - || otg->phy->state != OTG_STATE_B_IDLE) 665 + if (!otg || otg->phy->state != OTG_STATE_B_IDLE) 666 + return -ENODEV; 667 + 668 + otg_dev = container_of(otg->phy, struct fsl_otg, phy); 669 + if (otg_dev != fsl_otg_dev) 674 670 return -ENODEV; 675 671 676 672 otg_dev->fsm.b_bus_req = 1; ··· 685 675 /* A_host suspend will call this function to start hnp */ 686 676 static int fsl_otg_start_hnp(struct usb_otg *otg) 687 677 { 688 - struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); 678 + struct fsl_otg *otg_dev; 689 679 690 - if (!otg || otg_dev != fsl_otg_dev) 680 + if (!otg) 681 + return -ENODEV; 682 + 683 + otg_dev = container_of(otg->phy, struct fsl_otg, phy); 684 + if (otg_dev != fsl_otg_dev) 691 685 return -ENODEV; 692 686 693 687 DBG("start_hnp...n");
+35 -3
drivers/usb/otg/mxs-phy.c
··· 20 20 #include <linux/delay.h> 21 21 #include <linux/err.h> 22 22 #include <linux/io.h> 23 + #include <linux/workqueue.h> 23 24 24 25 #define DRIVER_NAME "mxs_phy" 25 26 ··· 35 34 #define BM_USBPHY_CTRL_ENUTMILEVEL2 BIT(14) 36 35 #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT BIT(1) 37 36 37 + /* 38 + * Amount of delay in miliseconds to safely enable ENHOSTDISCONDETECT bit 39 + * so that connection and reset processing can be completed for the root hub. 40 + */ 41 + #define MXY_PHY_ENHOSTDISCONDETECT_DELAY 250 42 + 38 43 struct mxs_phy { 39 44 struct usb_phy phy; 40 45 struct clk *clk; 46 + struct delayed_work enhostdiscondetect_work; 41 47 }; 42 48 43 49 #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy) ··· 70 62 71 63 clk_prepare_enable(mxs_phy->clk); 72 64 mxs_phy_hw_init(mxs_phy); 65 + INIT_DELAYED_WORK(&mxs_phy->enhostdiscondetect_work, NULL); 73 66 74 67 return 0; 75 68 } ··· 85 76 clk_disable_unprepare(mxs_phy->clk); 86 77 } 87 78 79 + static void mxs_phy_enhostdiscondetect_delay(struct work_struct *ws) 80 + { 81 + struct mxs_phy *mxs_phy = container_of(ws, struct mxs_phy, 82 + enhostdiscondetect_work.work); 83 + 84 + /* Enable HOSTDISCONDETECT after delay. */ 85 + dev_dbg(mxs_phy->phy.dev, "Setting ENHOSTDISCONDETECT\n"); 86 + writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT, 87 + mxs_phy->phy.io_priv + HW_USBPHY_CTRL_SET); 88 + } 89 + 88 90 static int mxs_phy_on_connect(struct usb_phy *phy, int port) 89 91 { 92 + struct mxs_phy *mxs_phy = to_mxs_phy(phy); 93 + 90 94 dev_dbg(phy->dev, "Connect on port %d\n", port); 91 95 92 - mxs_phy_hw_init(to_mxs_phy(phy)); 93 - writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT, 94 - phy->io_priv + HW_USBPHY_CTRL_SET); 96 + mxs_phy_hw_init(mxs_phy); 97 + 98 + /* 99 + * Delay enabling ENHOSTDISCONDETECT so that connection and 100 + * reset processing can be completed for the root hub. 101 + */ 102 + dev_dbg(phy->dev, "Delaying setting ENHOSTDISCONDETECT\n"); 103 + PREPARE_DELAYED_WORK(&mxs_phy->enhostdiscondetect_work, 104 + mxs_phy_enhostdiscondetect_delay); 105 + schedule_delayed_work(&mxs_phy->enhostdiscondetect_work, 106 + msecs_to_jiffies(MXY_PHY_ENHOSTDISCONDETECT_DELAY)); 95 107 96 108 return 0; 97 109 } ··· 121 91 { 122 92 dev_dbg(phy->dev, "Disconnect on port %d\n", port); 123 93 94 + /* No need to delay before clearing ENHOSTDISCONDETECT. */ 95 + dev_dbg(phy->dev, "Clearing ENHOSTDISCONDETECT\n"); 124 96 writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT, 125 97 phy->io_priv + HW_USBPHY_CTRL_CLR); 126 98
+7 -1
drivers/usb/otg/nop-usb-xceiv.c
··· 30 30 #include <linux/platform_device.h> 31 31 #include <linux/dma-mapping.h> 32 32 #include <linux/usb/otg.h> 33 + #include <linux/usb/nop-usb-xceiv.h> 33 34 #include <linux/slab.h> 34 35 35 36 struct nop_usb_xceiv { ··· 95 94 96 95 static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev) 97 96 { 97 + struct nop_usb_xceiv_platform_data *pdata = pdev->dev.platform_data; 98 98 struct nop_usb_xceiv *nop; 99 + enum usb_phy_type type = USB_PHY_TYPE_USB2; 99 100 int err; 100 101 101 102 nop = kzalloc(sizeof *nop, GFP_KERNEL); ··· 110 107 return -ENOMEM; 111 108 } 112 109 110 + if (pdata) 111 + type = pdata->type; 112 + 113 113 nop->dev = &pdev->dev; 114 114 nop->phy.dev = nop->dev; 115 115 nop->phy.label = "nop-xceiv"; ··· 123 117 nop->phy.otg->set_host = nop_set_host; 124 118 nop->phy.otg->set_peripheral = nop_set_peripheral; 125 119 126 - err = usb_add_phy(&nop->phy, USB_PHY_TYPE_USB2); 120 + err = usb_add_phy(&nop->phy, type); 127 121 if (err) { 128 122 dev_err(&pdev->dev, "can't register transceiver, err: %d\n", 129 123 err);
+1 -1
drivers/usb/otg/otg.c
··· 159 159 unsigned long flags; 160 160 struct usb_phy *phy; 161 161 162 - if (x && x->type != USB_PHY_TYPE_UNDEFINED) { 162 + if (x->type != USB_PHY_TYPE_UNDEFINED) { 163 163 dev_err(x->dev, "not accepting initialized PHY %s\n", x->label); 164 164 return -EINVAL; 165 165 }
+20 -6
drivers/usb/otg/twl4030-usb.c
··· 585 585 struct twl4030_usb *twl; 586 586 int status, err; 587 587 struct usb_otg *otg; 588 - 589 - if (!pdata) { 590 - dev_dbg(&pdev->dev, "platform_data not available\n"); 591 - return -EINVAL; 592 - } 588 + struct device_node *np = pdev->dev.of_node; 593 589 594 590 twl = devm_kzalloc(&pdev->dev, sizeof *twl, GFP_KERNEL); 595 591 if (!twl) 596 592 return -ENOMEM; 593 + 594 + if (np) 595 + of_property_read_u32(np, "usb_mode", 596 + (enum twl4030_usb_mode *)&twl->usb_mode); 597 + else if (pdata) 598 + twl->usb_mode = pdata->usb_mode; 599 + else { 600 + dev_err(&pdev->dev, "twl4030 initialized without pdata\n"); 601 + return -EINVAL; 602 + } 597 603 598 604 otg = devm_kzalloc(&pdev->dev, sizeof *otg, GFP_KERNEL); 599 605 if (!otg) ··· 607 601 608 602 twl->dev = &pdev->dev; 609 603 twl->irq = platform_get_irq(pdev, 0); 610 - twl->usb_mode = pdata->usb_mode; 611 604 twl->vbus_supplied = false; 612 605 twl->asleep = 1; 613 606 twl->linkstat = OMAP_MUSB_UNKNOWN; ··· 695 690 return 0; 696 691 } 697 692 693 + #ifdef CONFIG_OF 694 + static const struct of_device_id twl4030_usb_id_table[] = { 695 + { .compatible = "ti,twl4030-usb" }, 696 + {} 697 + }; 698 + MODULE_DEVICE_TABLE(of, twl4030_usb_id_table); 699 + #endif 700 + 698 701 static struct platform_driver twl4030_usb_driver = { 699 702 .probe = twl4030_usb_probe, 700 703 .remove = __exit_p(twl4030_usb_remove), 701 704 .driver = { 702 705 .name = "twl4030_usb", 703 706 .owner = THIS_MODULE, 707 + .of_match_table = of_match_ptr(twl4030_usb_id_table), 704 708 }, 705 709 }; 706 710
+44 -113
drivers/usb/otg/twl6030-usb.c
··· 25 25 #include <linux/interrupt.h> 26 26 #include <linux/platform_device.h> 27 27 #include <linux/io.h> 28 - #include <linux/usb/otg.h> 29 28 #include <linux/usb/musb-omap.h> 29 + #include <linux/usb/phy_companion.h> 30 + #include <linux/usb/omap_usb.h> 30 31 #include <linux/i2c/twl.h> 31 32 #include <linux/regulator/consumer.h> 32 33 #include <linux/err.h> ··· 88 87 #define VBUS_DET BIT(2) 89 88 90 89 struct twl6030_usb { 91 - struct usb_phy phy; 90 + struct phy_companion comparator; 92 91 struct device *dev; 93 92 94 93 /* for vbus reporting with irqs disabled */ ··· 105 104 u8 asleep; 106 105 bool irq_enabled; 107 106 bool vbus_enable; 108 - unsigned long features; 107 + const char *regulator; 109 108 }; 110 109 111 - #define phy_to_twl(x) container_of((x), struct twl6030_usb, phy) 110 + #define comparator_to_twl(x) container_of((x), struct twl6030_usb, comparator) 112 111 113 112 /*-------------------------------------------------------------------------*/ 114 113 ··· 138 137 return ret; 139 138 } 140 139 141 - static int twl6030_phy_init(struct usb_phy *x) 140 + static int twl6030_start_srp(struct phy_companion *comparator) 142 141 { 143 - struct twl6030_usb *twl; 144 - struct device *dev; 145 - struct twl4030_usb_data *pdata; 146 - 147 - twl = phy_to_twl(x); 148 - dev = twl->dev; 149 - pdata = dev->platform_data; 150 - 151 - if (twl->linkstat == OMAP_MUSB_ID_GROUND) 152 - pdata->phy_power(twl->dev, 1, 1); 153 - else 154 - pdata->phy_power(twl->dev, 0, 1); 155 - 156 - return 0; 157 - } 158 - 159 - static void twl6030_phy_shutdown(struct usb_phy *x) 160 - { 161 - struct twl6030_usb *twl; 162 - struct device *dev; 163 - struct twl4030_usb_data *pdata; 164 - 165 - twl = phy_to_twl(x); 166 - dev = twl->dev; 167 - pdata = dev->platform_data; 168 - pdata->phy_power(twl->dev, 0, 0); 169 - } 170 - 171 - static int twl6030_phy_suspend(struct usb_phy *x, int suspend) 172 - { 173 - struct twl6030_usb *twl = phy_to_twl(x); 174 - struct device *dev = twl->dev; 175 - struct twl4030_usb_data *pdata = dev->platform_data; 176 - 177 - pdata->phy_suspend(dev, suspend); 178 - 179 - return 0; 180 - } 181 - 182 - static int twl6030_start_srp(struct usb_otg *otg) 183 - { 184 - struct twl6030_usb *twl = phy_to_twl(otg->phy); 142 + struct twl6030_usb *twl = comparator_to_twl(comparator); 185 143 186 144 twl6030_writeb(twl, TWL_MODULE_USB, 0x24, USB_VBUS_CTRL_SET); 187 145 twl6030_writeb(twl, TWL_MODULE_USB, 0x84, USB_VBUS_CTRL_SET); ··· 153 193 154 194 static int twl6030_usb_ldo_init(struct twl6030_usb *twl) 155 195 { 156 - char *regulator_name; 157 - 158 - if (twl->features & TWL6025_SUBCLASS) 159 - regulator_name = "ldousb"; 160 - else 161 - regulator_name = "vusb"; 162 - 163 196 /* Set to OTG_REV 1.3 and turn on the ID_WAKEUP_COMP */ 164 197 twl6030_writeb(twl, TWL6030_MODULE_ID0 , 0x1, TWL6030_BACKUP_REG); 165 198 ··· 162 209 /* Program MISC2 register and set bit VUSB_IN_VBAT */ 163 210 twl6030_writeb(twl, TWL6030_MODULE_ID0 , 0x10, TWL6030_MISC2); 164 211 165 - twl->usb3v3 = regulator_get(twl->dev, regulator_name); 212 + twl->usb3v3 = regulator_get(twl->dev, twl->regulator); 166 213 if (IS_ERR(twl->usb3v3)) 167 214 return -ENODEV; 168 215 ··· 266 313 return IRQ_HANDLED; 267 314 } 268 315 269 - static int twl6030_set_peripheral(struct usb_otg *otg, 270 - struct usb_gadget *gadget) 316 + static int twl6030_enable_irq(struct twl6030_usb *twl) 271 317 { 272 - if (!otg) 273 - return -ENODEV; 274 - 275 - otg->gadget = gadget; 276 - if (!gadget) 277 - otg->phy->state = OTG_STATE_UNDEFINED; 278 - 279 - return 0; 280 - } 281 - 282 - static int twl6030_enable_irq(struct usb_phy *x) 283 - { 284 - struct twl6030_usb *twl = phy_to_twl(x); 285 - 286 318 twl6030_writeb(twl, TWL_MODULE_USB, 0x1, USB_ID_INT_EN_HI_SET); 287 319 twl6030_interrupt_unmask(0x05, REG_INT_MSK_LINE_C); 288 320 twl6030_interrupt_unmask(0x05, REG_INT_MSK_STS_C); ··· 300 362 CHARGERUSB_CTRL1); 301 363 } 302 364 303 - static int twl6030_set_vbus(struct usb_otg *otg, bool enabled) 365 + static int twl6030_set_vbus(struct phy_companion *comparator, bool enabled) 304 366 { 305 - struct twl6030_usb *twl = phy_to_twl(otg->phy); 367 + struct twl6030_usb *twl = comparator_to_twl(comparator); 306 368 307 369 twl->vbus_enable = enabled; 308 370 schedule_work(&twl->set_vbus_work); ··· 310 372 return 0; 311 373 } 312 374 313 - static int twl6030_set_host(struct usb_otg *otg, struct usb_bus *host) 314 - { 315 - if (!otg) 316 - return -ENODEV; 317 - 318 - otg->host = host; 319 - if (!host) 320 - otg->phy->state = OTG_STATE_UNDEFINED; 321 - return 0; 322 - } 323 - 324 375 static int __devinit twl6030_usb_probe(struct platform_device *pdev) 325 376 { 377 + u32 ret; 326 378 struct twl6030_usb *twl; 327 379 int status, err; 328 - struct twl4030_usb_data *pdata; 329 - struct usb_otg *otg; 330 - struct device *dev = &pdev->dev; 331 - pdata = dev->platform_data; 380 + struct device_node *np = pdev->dev.of_node; 381 + struct device *dev = &pdev->dev; 382 + struct twl4030_usb_data *pdata = dev->platform_data; 332 383 333 384 twl = devm_kzalloc(dev, sizeof *twl, GFP_KERNEL); 334 385 if (!twl) 335 386 return -ENOMEM; 336 387 337 - otg = devm_kzalloc(dev, sizeof *otg, GFP_KERNEL); 338 - if (!otg) 339 - return -ENOMEM; 340 - 341 388 twl->dev = &pdev->dev; 342 389 twl->irq1 = platform_get_irq(pdev, 0); 343 390 twl->irq2 = platform_get_irq(pdev, 1); 344 - twl->features = pdata->features; 345 391 twl->linkstat = OMAP_MUSB_UNKNOWN; 346 392 347 - twl->phy.dev = twl->dev; 348 - twl->phy.label = "twl6030"; 349 - twl->phy.otg = otg; 350 - twl->phy.init = twl6030_phy_init; 351 - twl->phy.shutdown = twl6030_phy_shutdown; 352 - twl->phy.set_suspend = twl6030_phy_suspend; 393 + twl->comparator.set_vbus = twl6030_set_vbus; 394 + twl->comparator.start_srp = twl6030_start_srp; 353 395 354 - otg->phy = &twl->phy; 355 - otg->set_host = twl6030_set_host; 356 - otg->set_peripheral = twl6030_set_peripheral; 357 - otg->set_vbus = twl6030_set_vbus; 358 - otg->start_srp = twl6030_start_srp; 396 + ret = omap_usb2_set_comparator(&twl->comparator); 397 + if (ret == -ENODEV) { 398 + dev_info(&pdev->dev, "phy not ready, deferring probe"); 399 + return -EPROBE_DEFER; 400 + } 401 + 402 + if (np) { 403 + twl->regulator = "usb"; 404 + } else if (pdata) { 405 + if (pdata->features & TWL6025_SUBCLASS) 406 + twl->regulator = "ldousb"; 407 + else 408 + twl->regulator = "vusb"; 409 + } else { 410 + dev_err(&pdev->dev, "twl6030 initialized without pdata\n"); 411 + return -EINVAL; 412 + } 359 413 360 414 /* init spinlock for workqueue */ 361 415 spin_lock_init(&twl->lock); ··· 357 427 dev_err(&pdev->dev, "ldo init failed\n"); 358 428 return err; 359 429 } 360 - usb_add_phy(&twl->phy, USB_PHY_TYPE_USB2); 361 430 362 431 platform_set_drvdata(pdev, twl); 363 432 if (device_create_file(&pdev->dev, &dev_attr_vbus)) ··· 387 458 } 388 459 389 460 twl->asleep = 0; 390 - pdata->phy_init(dev); 391 - twl6030_phy_suspend(&twl->phy, 0); 392 - twl6030_enable_irq(&twl->phy); 461 + twl6030_enable_irq(twl); 393 462 dev_info(&pdev->dev, "Initialized TWL6030 USB module\n"); 394 463 395 464 return 0; ··· 397 470 { 398 471 struct twl6030_usb *twl = platform_get_drvdata(pdev); 399 472 400 - struct twl4030_usb_data *pdata; 401 - struct device *dev = &pdev->dev; 402 - pdata = dev->platform_data; 403 - 404 473 twl6030_interrupt_mask(TWL6030_USBOTG_INT_MASK, 405 474 REG_INT_MSK_LINE_C); 406 475 twl6030_interrupt_mask(TWL6030_USBOTG_INT_MASK, ··· 404 481 free_irq(twl->irq1, twl); 405 482 free_irq(twl->irq2, twl); 406 483 regulator_put(twl->usb3v3); 407 - pdata->phy_exit(twl->dev); 408 484 device_remove_file(twl->dev, &dev_attr_vbus); 409 485 cancel_work_sync(&twl->set_vbus_work); 410 486 411 487 return 0; 412 488 } 489 + 490 + #ifdef CONFIG_OF 491 + static const struct of_device_id twl6030_usb_id_table[] = { 492 + { .compatible = "ti,twl6030-usb" }, 493 + {} 494 + }; 495 + MODULE_DEVICE_TABLE(of, twl6030_usb_id_table); 496 + #endif 413 497 414 498 static struct platform_driver twl6030_usb_driver = { 415 499 .probe = twl6030_usb_probe, ··· 424 494 .driver = { 425 495 .name = "twl6030_usb", 426 496 .owner = THIS_MODULE, 497 + .of_match_table = of_match_ptr(twl6030_usb_id_table), 427 498 }, 428 499 }; 429 500
+17
drivers/usb/phy/Kconfig
··· 4 4 comment "USB Physical Layer drivers" 5 5 depends on USB || USB_GADGET 6 6 7 + config OMAP_USB2 8 + tristate "OMAP USB2 PHY Driver" 9 + select USB_OTG_UTILS 10 + help 11 + Enable this to support the transceiver that is part of SOC. This 12 + driver takes care of all the PHY functionality apart from comparator. 13 + The USB OTG controller communicates with the comparator using this 14 + driver. 15 + 7 16 config USB_ISP1301 8 17 tristate "NXP ISP1301 USB transceiver support" 9 18 depends on USB || USB_GADGET ··· 24 15 25 16 To compile this driver as a module, choose M here: the 26 17 module will be called isp1301. 18 + 19 + config MV_U3D_PHY 20 + bool "Marvell USB 3.0 PHY controller Driver" 21 + depends on USB_MV_U3D 22 + select USB_OTG_UTILS 23 + help 24 + Enable this to support Marvell USB 3.0 phy controller for Marvell 25 + SoC.
+3
drivers/usb/phy/Makefile
··· 4 4 5 5 ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG 6 6 7 + obj-$(CONFIG_OMAP_USB2) += omap-usb2.o 7 8 obj-$(CONFIG_USB_ISP1301) += isp1301.o 9 + obj-$(CONFIG_MV_U3D_PHY) += mv_u3d_phy.o 10 + obj-$(CONFIG_USB_EHCI_TEGRA) += tegra_usb_phy.o
+345
drivers/usb/phy/mv_u3d_phy.c
··· 1 + /* 2 + * Copyright (C) 2011 Marvell International Ltd. All rights reserved. 3 + * 4 + * This program is free software; you can redistribute it and/or modify it 5 + * under the terms and conditions of the GNU General Public License, 6 + * version 2, as published by the Free Software Foundation. 7 + */ 8 + 9 + #include <linux/module.h> 10 + #include <linux/platform_device.h> 11 + #include <linux/clk.h> 12 + #include <linux/delay.h> 13 + #include <linux/err.h> 14 + #include <linux/io.h> 15 + #include <linux/usb/otg.h> 16 + #include <linux/platform_data/mv_usb.h> 17 + 18 + #include "mv_u3d_phy.h" 19 + 20 + /* 21 + * struct mv_u3d_phy - transceiver driver state 22 + * @phy: transceiver structure 23 + * @dev: The parent device supplied to the probe function 24 + * @clk: usb phy clock 25 + * @base: usb phy register memory base 26 + */ 27 + struct mv_u3d_phy { 28 + struct usb_phy phy; 29 + struct mv_usb_platform_data *plat; 30 + struct device *dev; 31 + struct clk *clk; 32 + void __iomem *base; 33 + }; 34 + 35 + static u32 mv_u3d_phy_read(void __iomem *base, u32 reg) 36 + { 37 + void __iomem *addr, *data; 38 + 39 + addr = base; 40 + data = base + 0x4; 41 + 42 + writel_relaxed(reg, addr); 43 + return readl_relaxed(data); 44 + } 45 + 46 + static void mv_u3d_phy_set(void __iomem *base, u32 reg, u32 value) 47 + { 48 + void __iomem *addr, *data; 49 + u32 tmp; 50 + 51 + addr = base; 52 + data = base + 0x4; 53 + 54 + writel_relaxed(reg, addr); 55 + tmp = readl_relaxed(data); 56 + tmp |= value; 57 + writel_relaxed(tmp, data); 58 + } 59 + 60 + static void mv_u3d_phy_clear(void __iomem *base, u32 reg, u32 value) 61 + { 62 + void __iomem *addr, *data; 63 + u32 tmp; 64 + 65 + addr = base; 66 + data = base + 0x4; 67 + 68 + writel_relaxed(reg, addr); 69 + tmp = readl_relaxed(data); 70 + tmp &= ~value; 71 + writel_relaxed(tmp, data); 72 + } 73 + 74 + static void mv_u3d_phy_write(void __iomem *base, u32 reg, u32 value) 75 + { 76 + void __iomem *addr, *data; 77 + 78 + addr = base; 79 + data = base + 0x4; 80 + 81 + writel_relaxed(reg, addr); 82 + writel_relaxed(value, data); 83 + } 84 + 85 + void mv_u3d_phy_shutdown(struct usb_phy *phy) 86 + { 87 + struct mv_u3d_phy *mv_u3d_phy; 88 + void __iomem *base; 89 + u32 val; 90 + 91 + mv_u3d_phy = container_of(phy, struct mv_u3d_phy, phy); 92 + base = mv_u3d_phy->base; 93 + 94 + /* Power down Reference Analog current, bit 15 95 + * Power down PLL, bit 14 96 + * Power down Receiver, bit 13 97 + * Power down Transmitter, bit 12 98 + * of USB3_POWER_PLL_CONTROL register 99 + */ 100 + val = mv_u3d_phy_read(base, USB3_POWER_PLL_CONTROL); 101 + val &= ~(USB3_POWER_PLL_CONTROL_PU); 102 + mv_u3d_phy_write(base, USB3_POWER_PLL_CONTROL, val); 103 + 104 + if (mv_u3d_phy->clk) 105 + clk_disable(mv_u3d_phy->clk); 106 + } 107 + 108 + static int mv_u3d_phy_init(struct usb_phy *phy) 109 + { 110 + struct mv_u3d_phy *mv_u3d_phy; 111 + void __iomem *base; 112 + u32 val, count; 113 + 114 + /* enable usb3 phy */ 115 + mv_u3d_phy = container_of(phy, struct mv_u3d_phy, phy); 116 + 117 + if (mv_u3d_phy->clk) 118 + clk_enable(mv_u3d_phy->clk); 119 + 120 + base = mv_u3d_phy->base; 121 + 122 + val = mv_u3d_phy_read(base, USB3_POWER_PLL_CONTROL); 123 + val &= ~(USB3_POWER_PLL_CONTROL_PU_MASK); 124 + val |= 0xF << USB3_POWER_PLL_CONTROL_PU_SHIFT; 125 + mv_u3d_phy_write(base, USB3_POWER_PLL_CONTROL, val); 126 + udelay(100); 127 + 128 + mv_u3d_phy_write(base, USB3_RESET_CONTROL, 129 + USB3_RESET_CONTROL_RESET_PIPE); 130 + udelay(100); 131 + 132 + mv_u3d_phy_write(base, USB3_RESET_CONTROL, 133 + USB3_RESET_CONTROL_RESET_PIPE 134 + | USB3_RESET_CONTROL_RESET_PHY); 135 + udelay(100); 136 + 137 + val = mv_u3d_phy_read(base, USB3_POWER_PLL_CONTROL); 138 + val &= ~(USB3_POWER_PLL_CONTROL_REF_FREF_SEL_MASK 139 + | USB3_POWER_PLL_CONTROL_PHY_MODE_MASK); 140 + val |= (USB3_PLL_25MHZ << USB3_POWER_PLL_CONTROL_REF_FREF_SEL_SHIFT) 141 + | (0x5 << USB3_POWER_PLL_CONTROL_PHY_MODE_SHIFT); 142 + mv_u3d_phy_write(base, USB3_POWER_PLL_CONTROL, val); 143 + udelay(100); 144 + 145 + mv_u3d_phy_clear(base, USB3_KVCO_CALI_CONTROL, 146 + USB3_KVCO_CALI_CONTROL_USE_MAX_PLL_RATE_MASK); 147 + udelay(100); 148 + 149 + val = mv_u3d_phy_read(base, USB3_SQUELCH_FFE); 150 + val &= ~(USB3_SQUELCH_FFE_FFE_CAP_SEL_MASK 151 + | USB3_SQUELCH_FFE_FFE_RES_SEL_MASK 152 + | USB3_SQUELCH_FFE_SQ_THRESH_IN_MASK); 153 + val |= ((0xD << USB3_SQUELCH_FFE_FFE_CAP_SEL_SHIFT) 154 + | (0x7 << USB3_SQUELCH_FFE_FFE_RES_SEL_SHIFT) 155 + | (0x8 << USB3_SQUELCH_FFE_SQ_THRESH_IN_SHIFT)); 156 + mv_u3d_phy_write(base, USB3_SQUELCH_FFE, val); 157 + udelay(100); 158 + 159 + val = mv_u3d_phy_read(base, USB3_GEN1_SET0); 160 + val &= ~USB3_GEN1_SET0_G1_TX_SLEW_CTRL_EN_MASK; 161 + val |= 1 << USB3_GEN1_SET0_G1_TX_EMPH_EN_SHIFT; 162 + mv_u3d_phy_write(base, USB3_GEN1_SET0, val); 163 + udelay(100); 164 + 165 + val = mv_u3d_phy_read(base, USB3_GEN2_SET0); 166 + val &= ~(USB3_GEN2_SET0_G2_TX_AMP_MASK 167 + | USB3_GEN2_SET0_G2_TX_EMPH_AMP_MASK 168 + | USB3_GEN2_SET0_G2_TX_SLEW_CTRL_EN_MASK); 169 + val |= ((0x14 << USB3_GEN2_SET0_G2_TX_AMP_SHIFT) 170 + | (1 << USB3_GEN2_SET0_G2_TX_AMP_ADJ_SHIFT) 171 + | (0xA << USB3_GEN2_SET0_G2_TX_EMPH_AMP_SHIFT) 172 + | (1 << USB3_GEN2_SET0_G2_TX_EMPH_EN_SHIFT)); 173 + mv_u3d_phy_write(base, USB3_GEN2_SET0, val); 174 + udelay(100); 175 + 176 + mv_u3d_phy_read(base, USB3_TX_EMPPH); 177 + val &= ~(USB3_TX_EMPPH_AMP_MASK 178 + | USB3_TX_EMPPH_EN_MASK 179 + | USB3_TX_EMPPH_AMP_FORCE_MASK 180 + | USB3_TX_EMPPH_PAR1_MASK 181 + | USB3_TX_EMPPH_PAR2_MASK); 182 + val |= ((0xB << USB3_TX_EMPPH_AMP_SHIFT) 183 + | (1 << USB3_TX_EMPPH_EN_SHIFT) 184 + | (1 << USB3_TX_EMPPH_AMP_FORCE_SHIFT) 185 + | (0x1C << USB3_TX_EMPPH_PAR1_SHIFT) 186 + | (1 << USB3_TX_EMPPH_PAR2_SHIFT)); 187 + 188 + mv_u3d_phy_write(base, USB3_TX_EMPPH, val); 189 + udelay(100); 190 + 191 + val = mv_u3d_phy_read(base, USB3_GEN2_SET1); 192 + val &= ~(USB3_GEN2_SET1_G2_RX_SELMUPI_MASK 193 + | USB3_GEN2_SET1_G2_RX_SELMUPF_MASK 194 + | USB3_GEN2_SET1_G2_RX_SELMUFI_MASK 195 + | USB3_GEN2_SET1_G2_RX_SELMUFF_MASK); 196 + val |= ((1 << USB3_GEN2_SET1_G2_RX_SELMUPI_SHIFT) 197 + | (1 << USB3_GEN2_SET1_G2_RX_SELMUPF_SHIFT) 198 + | (1 << USB3_GEN2_SET1_G2_RX_SELMUFI_SHIFT) 199 + | (1 << USB3_GEN2_SET1_G2_RX_SELMUFF_SHIFT)); 200 + mv_u3d_phy_write(base, USB3_GEN2_SET1, val); 201 + udelay(100); 202 + 203 + val = mv_u3d_phy_read(base, USB3_DIGITAL_LOOPBACK_EN); 204 + val &= ~USB3_DIGITAL_LOOPBACK_EN_SEL_BITS_MASK; 205 + val |= 1 << USB3_DIGITAL_LOOPBACK_EN_SEL_BITS_SHIFT; 206 + mv_u3d_phy_write(base, USB3_DIGITAL_LOOPBACK_EN, val); 207 + udelay(100); 208 + 209 + val = mv_u3d_phy_read(base, USB3_IMPEDANCE_TX_SSC); 210 + val &= ~USB3_IMPEDANCE_TX_SSC_SSC_AMP_MASK; 211 + val |= 0xC << USB3_IMPEDANCE_TX_SSC_SSC_AMP_SHIFT; 212 + mv_u3d_phy_write(base, USB3_IMPEDANCE_TX_SSC, val); 213 + udelay(100); 214 + 215 + val = mv_u3d_phy_read(base, USB3_IMPEDANCE_CALI_CTRL); 216 + val &= ~USB3_IMPEDANCE_CALI_CTRL_IMP_CAL_THR_MASK; 217 + val |= 0x4 << USB3_IMPEDANCE_CALI_CTRL_IMP_CAL_THR_SHIFT; 218 + mv_u3d_phy_write(base, USB3_IMPEDANCE_CALI_CTRL, val); 219 + udelay(100); 220 + 221 + val = mv_u3d_phy_read(base, USB3_PHY_ISOLATION_MODE); 222 + val &= ~(USB3_PHY_ISOLATION_MODE_PHY_GEN_RX_MASK 223 + | USB3_PHY_ISOLATION_MODE_PHY_GEN_TX_MASK 224 + | USB3_PHY_ISOLATION_MODE_TX_DRV_IDLE_MASK); 225 + val |= ((1 << USB3_PHY_ISOLATION_MODE_PHY_GEN_RX_SHIFT) 226 + | (1 << USB3_PHY_ISOLATION_MODE_PHY_GEN_TX_SHIFT)); 227 + mv_u3d_phy_write(base, USB3_PHY_ISOLATION_MODE, val); 228 + udelay(100); 229 + 230 + val = mv_u3d_phy_read(base, USB3_TXDETRX); 231 + val &= ~(USB3_TXDETRX_VTHSEL_MASK); 232 + val |= 0x1 << USB3_TXDETRX_VTHSEL_SHIFT; 233 + mv_u3d_phy_write(base, USB3_TXDETRX, val); 234 + udelay(100); 235 + 236 + dev_dbg(mv_u3d_phy->dev, "start calibration\n"); 237 + 238 + calstart: 239 + /* Perform Manual Calibration */ 240 + mv_u3d_phy_set(base, USB3_KVCO_CALI_CONTROL, 241 + 1 << USB3_KVCO_CALI_CONTROL_CAL_START_SHIFT); 242 + 243 + mdelay(1); 244 + 245 + count = 0; 246 + while (1) { 247 + val = mv_u3d_phy_read(base, USB3_KVCO_CALI_CONTROL); 248 + if (val & (1 << USB3_KVCO_CALI_CONTROL_CAL_DONE_SHIFT)) 249 + break; 250 + else if (count > 50) { 251 + dev_dbg(mv_u3d_phy->dev, "calibration failure, retry...\n"); 252 + goto calstart; 253 + } 254 + count++; 255 + mdelay(1); 256 + } 257 + 258 + /* active PIPE interface */ 259 + mv_u3d_phy_write(base, USB3_PIPE_SM_CTRL, 260 + 1 << USB3_PIPE_SM_CTRL_PHY_INIT_DONE); 261 + 262 + return 0; 263 + } 264 + 265 + static int __devinit mv_u3d_phy_probe(struct platform_device *pdev) 266 + { 267 + struct mv_u3d_phy *mv_u3d_phy; 268 + struct mv_usb_platform_data *pdata; 269 + struct device *dev = &pdev->dev; 270 + struct resource *res; 271 + void __iomem *phy_base; 272 + int ret; 273 + 274 + pdata = pdev->dev.platform_data; 275 + if (!pdata) { 276 + dev_err(&pdev->dev, "%s: no platform data defined\n", __func__); 277 + return -EINVAL; 278 + } 279 + 280 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 281 + if (!res) { 282 + dev_err(dev, "missing mem resource\n"); 283 + return -ENODEV; 284 + } 285 + 286 + phy_base = devm_request_and_ioremap(dev, res); 287 + if (!phy_base) { 288 + dev_err(dev, "%s: register mapping failed\n", __func__); 289 + return -ENXIO; 290 + } 291 + 292 + mv_u3d_phy = devm_kzalloc(dev, sizeof(*mv_u3d_phy), GFP_KERNEL); 293 + if (!mv_u3d_phy) 294 + return -ENOMEM; 295 + 296 + mv_u3d_phy->dev = &pdev->dev; 297 + mv_u3d_phy->plat = pdata; 298 + mv_u3d_phy->base = phy_base; 299 + mv_u3d_phy->phy.dev = mv_u3d_phy->dev; 300 + mv_u3d_phy->phy.label = "mv-u3d-phy"; 301 + mv_u3d_phy->phy.init = mv_u3d_phy_init; 302 + mv_u3d_phy->phy.shutdown = mv_u3d_phy_shutdown; 303 + 304 + ret = usb_add_phy(&mv_u3d_phy->phy, USB_PHY_TYPE_USB3); 305 + if (ret) 306 + goto err; 307 + 308 + if (!mv_u3d_phy->clk) 309 + mv_u3d_phy->clk = clk_get(mv_u3d_phy->dev, "u3dphy"); 310 + 311 + platform_set_drvdata(pdev, mv_u3d_phy); 312 + 313 + dev_info(&pdev->dev, "Initialized Marvell USB 3.0 PHY\n"); 314 + err: 315 + return ret; 316 + } 317 + 318 + static int __exit mv_u3d_phy_remove(struct platform_device *pdev) 319 + { 320 + struct mv_u3d_phy *mv_u3d_phy = platform_get_drvdata(pdev); 321 + 322 + usb_remove_phy(&mv_u3d_phy->phy); 323 + 324 + if (mv_u3d_phy->clk) { 325 + clk_put(mv_u3d_phy->clk); 326 + mv_u3d_phy->clk = NULL; 327 + } 328 + 329 + return 0; 330 + } 331 + 332 + static struct platform_driver mv_u3d_phy_driver = { 333 + .probe = mv_u3d_phy_probe, 334 + .remove = __devexit_p(mv_u3d_phy_remove), 335 + .driver = { 336 + .name = "mv-u3d-phy", 337 + .owner = THIS_MODULE, 338 + }, 339 + }; 340 + 341 + module_platform_driver(mv_u3d_phy_driver); 342 + MODULE_DESCRIPTION("Marvell USB 3.0 PHY controller"); 343 + MODULE_AUTHOR("Yu Xu <yuxu@marvell.com>"); 344 + MODULE_LICENSE("GPL"); 345 + MODULE_ALIAS("platform:mv-u3d-phy");
+105
drivers/usb/phy/mv_u3d_phy.h
··· 1 + /* 2 + * Copyright (C) 2011 Marvell International Ltd. All rights reserved. 3 + * 4 + * This program is free software; you can redistribute it and/or modify it 5 + * under the terms and conditions of the GNU General Public License, 6 + * version 2, as published by the Free Software Foundation. 7 + */ 8 + 9 + #ifndef __MV_U3D_PHY_H 10 + #define __MV_U3D_PHY_H 11 + 12 + #define USB3_POWER_PLL_CONTROL 0x1 13 + #define USB3_KVCO_CALI_CONTROL 0x2 14 + #define USB3_IMPEDANCE_CALI_CTRL 0x3 15 + #define USB3_IMPEDANCE_TX_SSC 0x4 16 + #define USB3_SQUELCH_FFE 0x6 17 + #define USB3_GEN1_SET0 0xD 18 + #define USB3_GEN2_SET0 0xF 19 + #define USB3_GEN2_SET1 0x10 20 + #define USB3_DIGITAL_LOOPBACK_EN 0x23 21 + #define USB3_PHY_ISOLATION_MODE 0x26 22 + #define USB3_TXDETRX 0x48 23 + #define USB3_TX_EMPPH 0x5E 24 + #define USB3_RESET_CONTROL 0x90 25 + #define USB3_PIPE_SM_CTRL 0x91 26 + 27 + #define USB3_RESET_CONTROL_RESET_PIPE 0x1 28 + #define USB3_RESET_CONTROL_RESET_PHY 0x2 29 + 30 + #define USB3_POWER_PLL_CONTROL_REF_FREF_SEL_MASK (0x1F << 0) 31 + #define USB3_POWER_PLL_CONTROL_REF_FREF_SEL_SHIFT 0 32 + #define USB3_PLL_25MHZ 0x2 33 + #define USB3_PLL_26MHZ 0x5 34 + #define USB3_POWER_PLL_CONTROL_PHY_MODE_MASK (0x7 << 5) 35 + #define USB3_POWER_PLL_CONTROL_PHY_MODE_SHIFT 5 36 + #define USB3_POWER_PLL_CONTROL_PU_MASK (0xF << 12) 37 + #define USB3_POWER_PLL_CONTROL_PU_SHIFT 12 38 + #define USB3_POWER_PLL_CONTROL_PU (0xF << 12) 39 + 40 + #define USB3_KVCO_CALI_CONTROL_USE_MAX_PLL_RATE_MASK (0x1 << 12) 41 + #define USB3_KVCO_CALI_CONTROL_USE_MAX_PLL_RATE_SHIFT 12 42 + #define USB3_KVCO_CALI_CONTROL_CAL_DONE_SHIFT 14 43 + #define USB3_KVCO_CALI_CONTROL_CAL_START_SHIFT 15 44 + 45 + #define USB3_SQUELCH_FFE_FFE_CAP_SEL_MASK 0xF 46 + #define USB3_SQUELCH_FFE_FFE_CAP_SEL_SHIFT 0 47 + #define USB3_SQUELCH_FFE_FFE_RES_SEL_MASK (0x7 << 4) 48 + #define USB3_SQUELCH_FFE_FFE_RES_SEL_SHIFT 4 49 + #define USB3_SQUELCH_FFE_SQ_THRESH_IN_MASK (0x1F << 8) 50 + #define USB3_SQUELCH_FFE_SQ_THRESH_IN_SHIFT 8 51 + 52 + #define USB3_GEN1_SET0_G1_TX_SLEW_CTRL_EN_MASK (0x1 << 15) 53 + #define USB3_GEN1_SET0_G1_TX_EMPH_EN_SHIFT 11 54 + 55 + #define USB3_GEN2_SET0_G2_TX_AMP_MASK (0x1F << 1) 56 + #define USB3_GEN2_SET0_G2_TX_AMP_SHIFT 1 57 + #define USB3_GEN2_SET0_G2_TX_AMP_ADJ_SHIFT 6 58 + #define USB3_GEN2_SET0_G2_TX_EMPH_AMP_MASK (0xF << 7) 59 + #define USB3_GEN2_SET0_G2_TX_EMPH_AMP_SHIFT 7 60 + #define USB3_GEN2_SET0_G2_TX_EMPH_EN_MASK (0x1 << 11) 61 + #define USB3_GEN2_SET0_G2_TX_EMPH_EN_SHIFT 11 62 + #define USB3_GEN2_SET0_G2_TX_SLEW_CTRL_EN_MASK (0x1 << 15) 63 + #define USB3_GEN2_SET0_G2_TX_SLEW_CTRL_EN_SHIFT 15 64 + 65 + #define USB3_GEN2_SET1_G2_RX_SELMUPI_MASK (0x7 << 0) 66 + #define USB3_GEN2_SET1_G2_RX_SELMUPI_SHIFT 0 67 + #define USB3_GEN2_SET1_G2_RX_SELMUPF_MASK (0x7 << 3) 68 + #define USB3_GEN2_SET1_G2_RX_SELMUPF_SHIFT 3 69 + #define USB3_GEN2_SET1_G2_RX_SELMUFI_MASK (0x3 << 6) 70 + #define USB3_GEN2_SET1_G2_RX_SELMUFI_SHIFT 6 71 + #define USB3_GEN2_SET1_G2_RX_SELMUFF_MASK (0x3 << 8) 72 + #define USB3_GEN2_SET1_G2_RX_SELMUFF_SHIFT 8 73 + 74 + #define USB3_DIGITAL_LOOPBACK_EN_SEL_BITS_MASK (0x3 << 10) 75 + #define USB3_DIGITAL_LOOPBACK_EN_SEL_BITS_SHIFT 10 76 + 77 + #define USB3_IMPEDANCE_CALI_CTRL_IMP_CAL_THR_MASK (0x7 << 12) 78 + #define USB3_IMPEDANCE_CALI_CTRL_IMP_CAL_THR_SHIFT 12 79 + 80 + #define USB3_IMPEDANCE_TX_SSC_SSC_AMP_MASK (0x3F << 0) 81 + #define USB3_IMPEDANCE_TX_SSC_SSC_AMP_SHIFT 0 82 + 83 + #define USB3_PHY_ISOLATION_MODE_PHY_GEN_RX_MASK 0xF 84 + #define USB3_PHY_ISOLATION_MODE_PHY_GEN_RX_SHIFT 0 85 + #define USB3_PHY_ISOLATION_MODE_PHY_GEN_TX_MASK (0xF << 4) 86 + #define USB3_PHY_ISOLATION_MODE_PHY_GEN_TX_SHIFT 4 87 + #define USB3_PHY_ISOLATION_MODE_TX_DRV_IDLE_MASK (0x1 << 8) 88 + 89 + #define USB3_TXDETRX_VTHSEL_MASK (0x3 << 4) 90 + #define USB3_TXDETRX_VTHSEL_SHIFT 4 91 + 92 + #define USB3_TX_EMPPH_AMP_MASK (0xF << 0) 93 + #define USB3_TX_EMPPH_AMP_SHIFT 0 94 + #define USB3_TX_EMPPH_EN_MASK (0x1 << 6) 95 + #define USB3_TX_EMPPH_EN_SHIFT 6 96 + #define USB3_TX_EMPPH_AMP_FORCE_MASK (0x1 << 7) 97 + #define USB3_TX_EMPPH_AMP_FORCE_SHIFT 7 98 + #define USB3_TX_EMPPH_PAR1_MASK (0x1F << 8) 99 + #define USB3_TX_EMPPH_PAR1_SHIFT 8 100 + #define USB3_TX_EMPPH_PAR2_MASK (0x1 << 13) 101 + #define USB3_TX_EMPPH_PAR2_SHIFT 13 102 + 103 + #define USB3_PIPE_SM_CTRL_PHY_INIT_DONE 15 104 + 105 + #endif /* __MV_U3D_PHY_H */
+271
drivers/usb/phy/omap-usb2.c
··· 1 + /* 2 + * omap-usb2.c - USB PHY, talking to musb controller in OMAP. 3 + * 4 + * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com 5 + * This program is free software; you can redistribute it and/or modify 6 + * it under the terms of the GNU General Public License as published by 7 + * the Free Software Foundation; either version 2 of the License, or 8 + * (at your option) any later version. 9 + * 10 + * Author: Kishon Vijay Abraham I <kishon@ti.com> 11 + * 12 + * This program is distributed in the hope that it will be useful, 13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 + * GNU General Public License for more details. 16 + * 17 + */ 18 + 19 + #include <linux/module.h> 20 + #include <linux/platform_device.h> 21 + #include <linux/slab.h> 22 + #include <linux/of.h> 23 + #include <linux/io.h> 24 + #include <linux/usb/omap_usb.h> 25 + #include <linux/usb/phy_companion.h> 26 + #include <linux/clk.h> 27 + #include <linux/err.h> 28 + #include <linux/pm_runtime.h> 29 + #include <linux/delay.h> 30 + 31 + /** 32 + * omap_usb2_set_comparator - links the comparator present in the sytem with 33 + * this phy 34 + * @comparator - the companion phy(comparator) for this phy 35 + * 36 + * The phy companion driver should call this API passing the phy_companion 37 + * filled with set_vbus and start_srp to be used by usb phy. 38 + * 39 + * For use by phy companion driver 40 + */ 41 + int omap_usb2_set_comparator(struct phy_companion *comparator) 42 + { 43 + struct omap_usb *phy; 44 + struct usb_phy *x = usb_get_phy(USB_PHY_TYPE_USB2); 45 + 46 + if (IS_ERR(x)) 47 + return -ENODEV; 48 + 49 + phy = phy_to_omapusb(x); 50 + phy->comparator = comparator; 51 + return 0; 52 + } 53 + EXPORT_SYMBOL_GPL(omap_usb2_set_comparator); 54 + 55 + /** 56 + * omap_usb_phy_power - power on/off the phy using control module reg 57 + * @phy: struct omap_usb * 58 + * @on: 0 or 1, based on powering on or off the PHY 59 + * 60 + * XXX: Remove this function once control module driver gets merged 61 + */ 62 + static void omap_usb_phy_power(struct omap_usb *phy, int on) 63 + { 64 + u32 val; 65 + 66 + if (on) { 67 + val = readl(phy->control_dev); 68 + if (val & PHY_PD) { 69 + writel(~PHY_PD, phy->control_dev); 70 + /* XXX: add proper documentation for this delay */ 71 + mdelay(200); 72 + } 73 + } else { 74 + writel(PHY_PD, phy->control_dev); 75 + } 76 + } 77 + 78 + static int omap_usb_set_vbus(struct usb_otg *otg, bool enabled) 79 + { 80 + struct omap_usb *phy = phy_to_omapusb(otg->phy); 81 + 82 + if (!phy->comparator) 83 + return -ENODEV; 84 + 85 + return phy->comparator->set_vbus(phy->comparator, enabled); 86 + } 87 + 88 + static int omap_usb_start_srp(struct usb_otg *otg) 89 + { 90 + struct omap_usb *phy = phy_to_omapusb(otg->phy); 91 + 92 + if (!phy->comparator) 93 + return -ENODEV; 94 + 95 + return phy->comparator->start_srp(phy->comparator); 96 + } 97 + 98 + static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host) 99 + { 100 + struct usb_phy *phy = otg->phy; 101 + 102 + otg->host = host; 103 + if (!host) 104 + phy->state = OTG_STATE_UNDEFINED; 105 + 106 + return 0; 107 + } 108 + 109 + static int omap_usb_set_peripheral(struct usb_otg *otg, 110 + struct usb_gadget *gadget) 111 + { 112 + struct usb_phy *phy = otg->phy; 113 + 114 + otg->gadget = gadget; 115 + if (!gadget) 116 + phy->state = OTG_STATE_UNDEFINED; 117 + 118 + return 0; 119 + } 120 + 121 + static int omap_usb2_suspend(struct usb_phy *x, int suspend) 122 + { 123 + u32 ret; 124 + struct omap_usb *phy = phy_to_omapusb(x); 125 + 126 + if (suspend && !phy->is_suspended) { 127 + omap_usb_phy_power(phy, 0); 128 + pm_runtime_put_sync(phy->dev); 129 + phy->is_suspended = 1; 130 + } else if (!suspend && phy->is_suspended) { 131 + ret = pm_runtime_get_sync(phy->dev); 132 + if (ret < 0) { 133 + dev_err(phy->dev, "get_sync failed with err %d\n", 134 + ret); 135 + return ret; 136 + } 137 + omap_usb_phy_power(phy, 1); 138 + phy->is_suspended = 0; 139 + } 140 + 141 + return 0; 142 + } 143 + 144 + static int __devinit omap_usb2_probe(struct platform_device *pdev) 145 + { 146 + struct omap_usb *phy; 147 + struct usb_otg *otg; 148 + struct resource *res; 149 + 150 + phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL); 151 + if (!phy) { 152 + dev_err(&pdev->dev, "unable to allocate memory for USB2 PHY\n"); 153 + return -ENOMEM; 154 + } 155 + 156 + otg = devm_kzalloc(&pdev->dev, sizeof(*otg), GFP_KERNEL); 157 + if (!otg) { 158 + dev_err(&pdev->dev, "unable to allocate memory for USB OTG\n"); 159 + return -ENOMEM; 160 + } 161 + 162 + phy->dev = &pdev->dev; 163 + 164 + phy->phy.dev = phy->dev; 165 + phy->phy.label = "omap-usb2"; 166 + phy->phy.set_suspend = omap_usb2_suspend; 167 + phy->phy.otg = otg; 168 + 169 + res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 170 + 171 + phy->control_dev = devm_request_and_ioremap(&pdev->dev, res); 172 + if (phy->control_dev == NULL) { 173 + dev_err(&pdev->dev, "Failed to obtain io memory\n"); 174 + return -ENXIO; 175 + } 176 + 177 + phy->is_suspended = 1; 178 + omap_usb_phy_power(phy, 0); 179 + 180 + otg->set_host = omap_usb_set_host; 181 + otg->set_peripheral = omap_usb_set_peripheral; 182 + otg->set_vbus = omap_usb_set_vbus; 183 + otg->start_srp = omap_usb_start_srp; 184 + otg->phy = &phy->phy; 185 + 186 + phy->wkupclk = devm_clk_get(phy->dev, "usb_phy_cm_clk32k"); 187 + if (IS_ERR(phy->wkupclk)) { 188 + dev_err(&pdev->dev, "unable to get usb_phy_cm_clk32k\n"); 189 + return PTR_ERR(phy->wkupclk); 190 + } 191 + clk_prepare(phy->wkupclk); 192 + 193 + usb_add_phy(&phy->phy, USB_PHY_TYPE_USB2); 194 + 195 + platform_set_drvdata(pdev, phy); 196 + 197 + pm_runtime_enable(phy->dev); 198 + 199 + return 0; 200 + } 201 + 202 + static int __devexit omap_usb2_remove(struct platform_device *pdev) 203 + { 204 + struct omap_usb *phy = platform_get_drvdata(pdev); 205 + 206 + clk_unprepare(phy->wkupclk); 207 + usb_remove_phy(&phy->phy); 208 + 209 + return 0; 210 + } 211 + 212 + #ifdef CONFIG_PM_RUNTIME 213 + 214 + static int omap_usb2_runtime_suspend(struct device *dev) 215 + { 216 + struct platform_device *pdev = to_platform_device(dev); 217 + struct omap_usb *phy = platform_get_drvdata(pdev); 218 + 219 + clk_disable(phy->wkupclk); 220 + 221 + return 0; 222 + } 223 + 224 + static int omap_usb2_runtime_resume(struct device *dev) 225 + { 226 + u32 ret = 0; 227 + struct platform_device *pdev = to_platform_device(dev); 228 + struct omap_usb *phy = platform_get_drvdata(pdev); 229 + 230 + ret = clk_enable(phy->wkupclk); 231 + if (ret < 0) 232 + dev_err(phy->dev, "Failed to enable wkupclk %d\n", ret); 233 + 234 + return ret; 235 + } 236 + 237 + static const struct dev_pm_ops omap_usb2_pm_ops = { 238 + SET_RUNTIME_PM_OPS(omap_usb2_runtime_suspend, omap_usb2_runtime_resume, 239 + NULL) 240 + }; 241 + 242 + #define DEV_PM_OPS (&omap_usb2_pm_ops) 243 + #else 244 + #define DEV_PM_OPS NULL 245 + #endif 246 + 247 + #ifdef CONFIG_OF 248 + static const struct of_device_id omap_usb2_id_table[] = { 249 + { .compatible = "ti,omap-usb2" }, 250 + {} 251 + }; 252 + MODULE_DEVICE_TABLE(of, omap_usb2_id_table); 253 + #endif 254 + 255 + static struct platform_driver omap_usb2_driver = { 256 + .probe = omap_usb2_probe, 257 + .remove = __devexit_p(omap_usb2_remove), 258 + .driver = { 259 + .name = "omap-usb2", 260 + .owner = THIS_MODULE, 261 + .pm = DEV_PM_OPS, 262 + .of_match_table = of_match_ptr(omap_usb2_id_table), 263 + }, 264 + }; 265 + 266 + module_platform_driver(omap_usb2_driver); 267 + 268 + MODULE_ALIAS("platform: omap_usb2"); 269 + MODULE_AUTHOR("Texas Instruments Inc."); 270 + MODULE_DESCRIPTION("OMAP USB2 phy driver"); 271 + MODULE_LICENSE("GPL v2");
+24
include/linux/usb/nop-usb-xceiv.h
··· 1 + #ifndef __LINUX_USB_NOP_XCEIV_H 2 + #define __LINUX_USB_NOP_XCEIV_H 3 + 4 + #include <linux/usb/otg.h> 5 + 6 + struct nop_usb_xceiv_platform_data { 7 + enum usb_phy_type type; 8 + }; 9 + 10 + #if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) && defined(MODULE)) 11 + /* sometimes transceivers are accessed only through e.g. ULPI */ 12 + extern void usb_nop_xceiv_register(void); 13 + extern void usb_nop_xceiv_unregister(void); 14 + #else 15 + static inline void usb_nop_xceiv_register(void) 16 + { 17 + } 18 + 19 + static inline void usb_nop_xceiv_unregister(void) 20 + { 21 + } 22 + #endif 23 + 24 + #endif /* __LINUX_USB_NOP_XCEIV_H */
+46
include/linux/usb/omap_usb.h
··· 1 + /* 2 + * omap_usb.h -- omap usb2 phy header file 3 + * 4 + * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com 5 + * This program is free software; you can redistribute it and/or modify 6 + * it under the terms of the GNU General Public License as published by 7 + * the Free Software Foundation; either version 2 of the License, or 8 + * (at your option) any later version. 9 + * 10 + * Author: Kishon Vijay Abraham I <kishon@ti.com> 11 + * 12 + * This program is distributed in the hope that it will be useful, 13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 + * GNU General Public License for more details. 16 + * 17 + */ 18 + 19 + #ifndef __DRIVERS_OMAP_USB2_H 20 + #define __DRIVERS_OMAP_USB2_H 21 + 22 + #include <linux/usb/otg.h> 23 + 24 + struct omap_usb { 25 + struct usb_phy phy; 26 + struct phy_companion *comparator; 27 + struct device *dev; 28 + u32 __iomem *control_dev; 29 + struct clk *wkupclk; 30 + u8 is_suspended:1; 31 + }; 32 + 33 + #define PHY_PD 0x1 34 + 35 + #define phy_to_omapusb(x) container_of((x), struct omap_usb, phy) 36 + 37 + #if defined(CONFIG_OMAP_USB2) || defined(CONFIG_OMAP_USB2_MODULE) 38 + extern int omap_usb2_set_comparator(struct phy_companion *comparator); 39 + #else 40 + static inline int omap_usb2_set_comparator(struct phy_companion *comparator) 41 + { 42 + return -ENODEV; 43 + } 44 + #endif 45 + 46 + #endif /* __DRIVERS_OMAP_USB_H */
+1 -235
include/linux/usb/otg.h
··· 9 9 #ifndef __LINUX_USB_OTG_H 10 10 #define __LINUX_USB_OTG_H 11 11 12 - #include <linux/notifier.h> 13 - 14 - /* OTG defines lots of enumeration states before device reset */ 15 - enum usb_otg_state { 16 - OTG_STATE_UNDEFINED = 0, 17 - 18 - /* single-role peripheral, and dual-role default-b */ 19 - OTG_STATE_B_IDLE, 20 - OTG_STATE_B_SRP_INIT, 21 - OTG_STATE_B_PERIPHERAL, 22 - 23 - /* extra dual-role default-b states */ 24 - OTG_STATE_B_WAIT_ACON, 25 - OTG_STATE_B_HOST, 26 - 27 - /* dual-role default-a */ 28 - OTG_STATE_A_IDLE, 29 - OTG_STATE_A_WAIT_VRISE, 30 - OTG_STATE_A_WAIT_BCON, 31 - OTG_STATE_A_HOST, 32 - OTG_STATE_A_SUSPEND, 33 - OTG_STATE_A_PERIPHERAL, 34 - OTG_STATE_A_WAIT_VFALL, 35 - OTG_STATE_A_VBUS_ERR, 36 - }; 37 - 38 - enum usb_phy_events { 39 - USB_EVENT_NONE, /* no events or cable disconnected */ 40 - USB_EVENT_VBUS, /* vbus valid event */ 41 - USB_EVENT_ID, /* id was grounded */ 42 - USB_EVENT_CHARGER, /* usb dedicated charger */ 43 - USB_EVENT_ENUMERATED, /* gadget driver enumerated */ 44 - }; 45 - 46 - /* associate a type with PHY */ 47 - enum usb_phy_type { 48 - USB_PHY_TYPE_UNDEFINED, 49 - USB_PHY_TYPE_USB2, 50 - USB_PHY_TYPE_USB3, 51 - }; 52 - 53 - struct usb_phy; 54 - 55 - /* for transceivers connected thru an ULPI interface, the user must 56 - * provide access ops 57 - */ 58 - struct usb_phy_io_ops { 59 - int (*read)(struct usb_phy *x, u32 reg); 60 - int (*write)(struct usb_phy *x, u32 val, u32 reg); 61 - }; 12 + #include <linux/usb/phy.h> 62 13 63 14 struct usb_otg { 64 15 u8 default_a; ··· 36 85 37 86 }; 38 87 39 - /* 40 - * the otg driver needs to interact with both device side and host side 41 - * usb controllers. it decides which controller is active at a given 42 - * moment, using the transceiver, ID signal, HNP and sometimes static 43 - * configuration information (including "board isn't wired for otg"). 44 - */ 45 - struct usb_phy { 46 - struct device *dev; 47 - const char *label; 48 - unsigned int flags; 49 - 50 - enum usb_phy_type type; 51 - enum usb_otg_state state; 52 - enum usb_phy_events last_event; 53 - 54 - struct usb_otg *otg; 55 - 56 - struct device *io_dev; 57 - struct usb_phy_io_ops *io_ops; 58 - void __iomem *io_priv; 59 - 60 - /* for notification of usb_phy_events */ 61 - struct atomic_notifier_head notifier; 62 - 63 - /* to pass extra port status to the root hub */ 64 - u16 port_status; 65 - u16 port_change; 66 - 67 - /* to support controllers that have multiple transceivers */ 68 - struct list_head head; 69 - 70 - /* initialize/shutdown the OTG controller */ 71 - int (*init)(struct usb_phy *x); 72 - void (*shutdown)(struct usb_phy *x); 73 - 74 - /* effective for B devices, ignored for A-peripheral */ 75 - int (*set_power)(struct usb_phy *x, 76 - unsigned mA); 77 - 78 - /* for non-OTG B devices: set transceiver into suspend mode */ 79 - int (*set_suspend)(struct usb_phy *x, 80 - int suspend); 81 - 82 - /* notify phy connect status change */ 83 - int (*notify_connect)(struct usb_phy *x, int port); 84 - int (*notify_disconnect)(struct usb_phy *x, int port); 85 - }; 86 - 87 - 88 - /* for board-specific init logic */ 89 - extern int usb_add_phy(struct usb_phy *, enum usb_phy_type type); 90 - extern void usb_remove_phy(struct usb_phy *); 91 - 92 - #if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) && defined(MODULE)) 93 - /* sometimes transceivers are accessed only through e.g. ULPI */ 94 - extern void usb_nop_xceiv_register(void); 95 - extern void usb_nop_xceiv_unregister(void); 96 - #else 97 - static inline void usb_nop_xceiv_register(void) 98 - { 99 - } 100 - 101 - static inline void usb_nop_xceiv_unregister(void) 102 - { 103 - } 104 - #endif 105 - 106 - /* helpers for direct access thru low-level io interface */ 107 - static inline int usb_phy_io_read(struct usb_phy *x, u32 reg) 108 - { 109 - if (x->io_ops && x->io_ops->read) 110 - return x->io_ops->read(x, reg); 111 - 112 - return -EINVAL; 113 - } 114 - 115 - static inline int usb_phy_io_write(struct usb_phy *x, u32 val, u32 reg) 116 - { 117 - if (x->io_ops && x->io_ops->write) 118 - return x->io_ops->write(x, val, reg); 119 - 120 - return -EINVAL; 121 - } 122 - 123 - static inline int 124 - usb_phy_init(struct usb_phy *x) 125 - { 126 - if (x->init) 127 - return x->init(x); 128 - 129 - return 0; 130 - } 131 - 132 - static inline void 133 - usb_phy_shutdown(struct usb_phy *x) 134 - { 135 - if (x->shutdown) 136 - x->shutdown(x); 137 - } 138 - 139 - /* for usb host and peripheral controller drivers */ 140 88 #ifdef CONFIG_USB_OTG_UTILS 141 - extern struct usb_phy *usb_get_phy(enum usb_phy_type type); 142 - extern struct usb_phy *devm_usb_get_phy(struct device *dev, 143 - enum usb_phy_type type); 144 - extern void usb_put_phy(struct usb_phy *); 145 - extern void devm_usb_put_phy(struct device *dev, struct usb_phy *x); 146 89 extern const char *otg_state_string(enum usb_otg_state state); 147 90 #else 148 - static inline struct usb_phy *usb_get_phy(enum usb_phy_type type) 149 - { 150 - return NULL; 151 - } 152 - 153 - static inline struct usb_phy *devm_usb_get_phy(struct device *dev, 154 - enum usb_phy_type type) 155 - { 156 - return NULL; 157 - } 158 - 159 - static inline void usb_put_phy(struct usb_phy *x) 160 - { 161 - } 162 - 163 - static inline void devm_usb_put_phy(struct device *dev, struct usb_phy *x) 164 - { 165 - } 166 - 167 91 static inline const char *otg_state_string(enum usb_otg_state state) 168 92 { 169 93 return NULL; ··· 88 262 } 89 263 90 264 static inline int 91 - usb_phy_set_power(struct usb_phy *x, unsigned mA) 92 - { 93 - if (x && x->set_power) 94 - return x->set_power(x, mA); 95 - return 0; 96 - } 97 - 98 - /* Context: can sleep */ 99 - static inline int 100 - usb_phy_set_suspend(struct usb_phy *x, int suspend) 101 - { 102 - if (x->set_suspend != NULL) 103 - return x->set_suspend(x, suspend); 104 - else 105 - return 0; 106 - } 107 - 108 - static inline int 109 - usb_phy_notify_connect(struct usb_phy *x, int port) 110 - { 111 - if (x->notify_connect) 112 - return x->notify_connect(x, port); 113 - else 114 - return 0; 115 - } 116 - 117 - static inline int 118 - usb_phy_notify_disconnect(struct usb_phy *x, int port) 119 - { 120 - if (x->notify_disconnect) 121 - return x->notify_disconnect(x, port); 122 - else 123 - return 0; 124 - } 125 - 126 - static inline int 127 265 otg_start_srp(struct usb_otg *otg) 128 266 { 129 267 if (otg && otg->start_srp) ··· 96 306 return -ENOTSUPP; 97 307 } 98 308 99 - /* notifiers */ 100 - static inline int 101 - usb_register_notifier(struct usb_phy *x, struct notifier_block *nb) 102 - { 103 - return atomic_notifier_chain_register(&x->notifier, nb); 104 - } 105 - 106 - static inline void 107 - usb_unregister_notifier(struct usb_phy *x, struct notifier_block *nb) 108 - { 109 - atomic_notifier_chain_unregister(&x->notifier, nb); 110 - } 111 - 112 309 /* for OTG controller drivers (and maybe other stuff) */ 113 310 extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num); 114 311 115 - static inline const char *usb_phy_type_string(enum usb_phy_type type) 116 - { 117 - switch (type) { 118 - case USB_PHY_TYPE_USB2: 119 - return "USB2 PHY"; 120 - case USB_PHY_TYPE_USB3: 121 - return "USB3 PHY"; 122 - default: 123 - return "UNKNOWN PHY TYPE"; 124 - } 125 - } 126 312 #endif /* __LINUX_USB_OTG_H */
+233
include/linux/usb/phy.h
··· 1 + /* USB OTG (On The Go) defines */ 2 + /* 3 + * 4 + * These APIs may be used between USB controllers. USB device drivers 5 + * (for either host or peripheral roles) don't use these calls; they 6 + * continue to use just usb_device and usb_gadget. 7 + */ 8 + 9 + #ifndef __LINUX_USB_PHY_H 10 + #define __LINUX_USB_PHY_H 11 + 12 + #include <linux/notifier.h> 13 + 14 + enum usb_phy_events { 15 + USB_EVENT_NONE, /* no events or cable disconnected */ 16 + USB_EVENT_VBUS, /* vbus valid event */ 17 + USB_EVENT_ID, /* id was grounded */ 18 + USB_EVENT_CHARGER, /* usb dedicated charger */ 19 + USB_EVENT_ENUMERATED, /* gadget driver enumerated */ 20 + }; 21 + 22 + /* associate a type with PHY */ 23 + enum usb_phy_type { 24 + USB_PHY_TYPE_UNDEFINED, 25 + USB_PHY_TYPE_USB2, 26 + USB_PHY_TYPE_USB3, 27 + }; 28 + 29 + /* OTG defines lots of enumeration states before device reset */ 30 + enum usb_otg_state { 31 + OTG_STATE_UNDEFINED = 0, 32 + 33 + /* single-role peripheral, and dual-role default-b */ 34 + OTG_STATE_B_IDLE, 35 + OTG_STATE_B_SRP_INIT, 36 + OTG_STATE_B_PERIPHERAL, 37 + 38 + /* extra dual-role default-b states */ 39 + OTG_STATE_B_WAIT_ACON, 40 + OTG_STATE_B_HOST, 41 + 42 + /* dual-role default-a */ 43 + OTG_STATE_A_IDLE, 44 + OTG_STATE_A_WAIT_VRISE, 45 + OTG_STATE_A_WAIT_BCON, 46 + OTG_STATE_A_HOST, 47 + OTG_STATE_A_SUSPEND, 48 + OTG_STATE_A_PERIPHERAL, 49 + OTG_STATE_A_WAIT_VFALL, 50 + OTG_STATE_A_VBUS_ERR, 51 + }; 52 + 53 + struct usb_phy; 54 + struct usb_otg; 55 + 56 + /* for transceivers connected thru an ULPI interface, the user must 57 + * provide access ops 58 + */ 59 + struct usb_phy_io_ops { 60 + int (*read)(struct usb_phy *x, u32 reg); 61 + int (*write)(struct usb_phy *x, u32 val, u32 reg); 62 + }; 63 + 64 + struct usb_phy { 65 + struct device *dev; 66 + const char *label; 67 + unsigned int flags; 68 + 69 + enum usb_phy_type type; 70 + enum usb_otg_state state; 71 + enum usb_phy_events last_event; 72 + 73 + struct usb_otg *otg; 74 + 75 + struct device *io_dev; 76 + struct usb_phy_io_ops *io_ops; 77 + void __iomem *io_priv; 78 + 79 + /* for notification of usb_phy_events */ 80 + struct atomic_notifier_head notifier; 81 + 82 + /* to pass extra port status to the root hub */ 83 + u16 port_status; 84 + u16 port_change; 85 + 86 + /* to support controllers that have multiple transceivers */ 87 + struct list_head head; 88 + 89 + /* initialize/shutdown the OTG controller */ 90 + int (*init)(struct usb_phy *x); 91 + void (*shutdown)(struct usb_phy *x); 92 + 93 + /* effective for B devices, ignored for A-peripheral */ 94 + int (*set_power)(struct usb_phy *x, 95 + unsigned mA); 96 + 97 + /* for non-OTG B devices: set transceiver into suspend mode */ 98 + int (*set_suspend)(struct usb_phy *x, 99 + int suspend); 100 + 101 + /* notify phy connect status change */ 102 + int (*notify_connect)(struct usb_phy *x, int port); 103 + int (*notify_disconnect)(struct usb_phy *x, int port); 104 + }; 105 + 106 + 107 + /* for board-specific init logic */ 108 + extern int usb_add_phy(struct usb_phy *, enum usb_phy_type type); 109 + extern void usb_remove_phy(struct usb_phy *); 110 + 111 + /* helpers for direct access thru low-level io interface */ 112 + static inline int usb_phy_io_read(struct usb_phy *x, u32 reg) 113 + { 114 + if (x->io_ops && x->io_ops->read) 115 + return x->io_ops->read(x, reg); 116 + 117 + return -EINVAL; 118 + } 119 + 120 + static inline int usb_phy_io_write(struct usb_phy *x, u32 val, u32 reg) 121 + { 122 + if (x->io_ops && x->io_ops->write) 123 + return x->io_ops->write(x, val, reg); 124 + 125 + return -EINVAL; 126 + } 127 + 128 + static inline int 129 + usb_phy_init(struct usb_phy *x) 130 + { 131 + if (x->init) 132 + return x->init(x); 133 + 134 + return 0; 135 + } 136 + 137 + static inline void 138 + usb_phy_shutdown(struct usb_phy *x) 139 + { 140 + if (x->shutdown) 141 + x->shutdown(x); 142 + } 143 + 144 + /* for usb host and peripheral controller drivers */ 145 + #ifdef CONFIG_USB_OTG_UTILS 146 + extern struct usb_phy *usb_get_phy(enum usb_phy_type type); 147 + extern struct usb_phy *devm_usb_get_phy(struct device *dev, 148 + enum usb_phy_type type); 149 + extern void usb_put_phy(struct usb_phy *); 150 + extern void devm_usb_put_phy(struct device *dev, struct usb_phy *x); 151 + #else 152 + static inline struct usb_phy *usb_get_phy(enum usb_phy_type type) 153 + { 154 + return NULL; 155 + } 156 + 157 + static inline struct usb_phy *devm_usb_get_phy(struct device *dev, 158 + enum usb_phy_type type) 159 + { 160 + return NULL; 161 + } 162 + 163 + static inline void usb_put_phy(struct usb_phy *x) 164 + { 165 + } 166 + 167 + static inline void devm_usb_put_phy(struct device *dev, struct usb_phy *x) 168 + { 169 + } 170 + 171 + #endif 172 + 173 + static inline int 174 + usb_phy_set_power(struct usb_phy *x, unsigned mA) 175 + { 176 + if (x && x->set_power) 177 + return x->set_power(x, mA); 178 + return 0; 179 + } 180 + 181 + /* Context: can sleep */ 182 + static inline int 183 + usb_phy_set_suspend(struct usb_phy *x, int suspend) 184 + { 185 + if (x->set_suspend != NULL) 186 + return x->set_suspend(x, suspend); 187 + else 188 + return 0; 189 + } 190 + 191 + static inline int 192 + usb_phy_notify_connect(struct usb_phy *x, int port) 193 + { 194 + if (x->notify_connect) 195 + return x->notify_connect(x, port); 196 + else 197 + return 0; 198 + } 199 + 200 + static inline int 201 + usb_phy_notify_disconnect(struct usb_phy *x, int port) 202 + { 203 + if (x->notify_disconnect) 204 + return x->notify_disconnect(x, port); 205 + else 206 + return 0; 207 + } 208 + 209 + /* notifiers */ 210 + static inline int 211 + usb_register_notifier(struct usb_phy *x, struct notifier_block *nb) 212 + { 213 + return atomic_notifier_chain_register(&x->notifier, nb); 214 + } 215 + 216 + static inline void 217 + usb_unregister_notifier(struct usb_phy *x, struct notifier_block *nb) 218 + { 219 + atomic_notifier_chain_unregister(&x->notifier, nb); 220 + } 221 + 222 + static inline const char *usb_phy_type_string(enum usb_phy_type type) 223 + { 224 + switch (type) { 225 + case USB_PHY_TYPE_USB2: 226 + return "USB2 PHY"; 227 + case USB_PHY_TYPE_USB3: 228 + return "USB3 PHY"; 229 + default: 230 + return "UNKNOWN PHY TYPE"; 231 + } 232 + } 233 + #endif /* __LINUX_USB_PHY_H */
+34
include/linux/usb/phy_companion.h
··· 1 + /* 2 + * phy-companion.h -- phy companion to indicate the comparator part of PHY 3 + * 4 + * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com 5 + * This program is free software; you can redistribute it and/or modify 6 + * it under the terms of the GNU General Public License as published by 7 + * the Free Software Foundation; either version 2 of the License, or 8 + * (at your option) any later version. 9 + * 10 + * Author: Kishon Vijay Abraham I <kishon@ti.com> 11 + * 12 + * This program is distributed in the hope that it will be useful, 13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 + * GNU General Public License for more details. 16 + * 17 + */ 18 + 19 + #ifndef __DRIVERS_PHY_COMPANION_H 20 + #define __DRIVERS_PHY_COMPANION_H 21 + 22 + #include <linux/usb/otg.h> 23 + 24 + /* phy_companion to take care of VBUS, ID and srp capabilities */ 25 + struct phy_companion { 26 + 27 + /* effective for A-peripheral, ignored for B devices */ 28 + int (*set_vbus)(struct phy_companion *x, bool enabled); 29 + 30 + /* for B devices only: start session with A-Host */ 31 + int (*start_srp)(struct phy_companion *x); 32 + }; 33 + 34 + #endif /* __DRIVERS_PHY_COMPANION_H */