Advertisement
mpthompson

imx23-olinuxino patches to enable USB

Aug 12th, 2012
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.85 KB | None | 0 0
  1. diff --git a/arch/arm/boot/dts/imx23-olinuxino.dts b/arch/arm/boot/dts/imx23-olinuxino.dts
  2. index a286873..77a589c 100644
  3. --- a/arch/arm/boot/dts/imx23-olinuxino.dts
  4. +++ b/arch/arm/boot/dts/imx23-olinuxino.dts
  5. @@ -31,6 +31,21 @@
  6. bus-width = <4>;
  7. status = "okay";
  8. };
  9. +
  10. + pinctrl@80018000 {
  11. + pinctrl-names = "default";
  12. + pinctrl-0 = <&hog_pins_a>;
  13. +
  14. + hog_pins_a: hog-gpios@0 {
  15. + reg = <0>;
  16. + fsl,pinmux-ids = <
  17. + 0x0113 /* MX23_PAD_GPMI_ALE__GPIO_0_17 */
  18. + >;
  19. + fsl,drive-strength = <2>;
  20. + fsl,voltage = <1>;
  21. + fsl,pull-up = <1>;
  22. + };
  23. + };
  24. };
  25.  
  26. apbx@80040000 {
  27. @@ -45,6 +60,32 @@
  28. pinctrl-0 = <&auart0_2pins_a>;
  29. status = "okay";
  30. };
  31. +
  32. + usbphy0: usbphy@8007c000 {
  33. + status = "okay";
  34. + };
  35. + };
  36. +
  37. + };
  38. +
  39. + ahb@80080000 {
  40. + usb0: usb@80080000 {
  41. + vbus-supply = <&reg_usb0_vbus>;
  42. + status = "okay";
  43. + };
  44. + };
  45. +
  46. + regulators {
  47. + compatible = "simple-bus";
  48. +
  49. + reg_usb0_vbus: usb0_vbus {
  50. + compatible = "regulator-fixed";
  51. + regulator-name = "usb0_vbus";
  52. + regulator-min-microvolt = <5000000>;
  53. + regulator-max-microvolt = <5000000>;
  54. + enable-active-high;
  55. + startup-delay-us = <300>; /* LAN9215 requires a POR of 200us minimum */
  56. + gpio = <&gpio0 17 0>;
  57. };
  58. };
  59. };
  60. diff --git a/arch/arm/boot/dts/imx23.dtsi b/arch/arm/boot/dts/imx23.dtsi
  61. index 9700872..5710630 100644
  62. --- a/arch/arm/boot/dts/imx23.dtsi
  63. +++ b/arch/arm/boot/dts/imx23.dtsi
  64. @@ -425,7 +425,8 @@
  65. status = "disabled";
  66. };
  67.  
  68. - usbphy@8007c000 {
  69. + usbphy0: usbphy@8007c000 {
  70. + compatible = "fsl,imx23-usbphy";
  71. reg = <0x8007c000 0x2000>;
  72. status = "disabled";
  73. };
  74. @@ -439,8 +440,11 @@
  75. reg = <0x80080000 0x80000>;
  76. ranges;
  77.  
  78. - usbctrl@80080000 {
  79. + usb0: usb@80080000 {
  80. + compatible = "fsl,imx23-usb", "fsl,imx27-usb";
  81. reg = <0x80080000 0x40000>;
  82. + interrupts = <11>;
  83. + fsl,usbphy = <&usbphy0>;
  84. status = "disabled";
  85. };
  86. };
  87. diff --git a/drivers/usb/otg/mxs-phy.c b/drivers/usb/otg/mxs-phy.c
  88. index c1a67cb..abacd3d 100644
  89. --- a/drivers/usb/otg/mxs-phy.c
  90. +++ b/drivers/usb/otg/mxs-phy.c
  91. @@ -24,10 +24,20 @@
  92. #define DRIVER_NAME "mxs_phy"
  93.  
  94. #define HW_USBPHY_PWD 0x00
  95. +#define HW_USBPHY_PWD_SET 0x04
  96. +#define HW_USBPHY_PWD_CLR 0x08
  97. #define HW_USBPHY_CTRL 0x30
  98. #define HW_USBPHY_CTRL_SET 0x34
  99. #define HW_USBPHY_CTRL_CLR 0x38
  100.  
  101. +#define BM_USBPHY_PWD_RXPWDRX BIT(20)
  102. +#define BM_USBPHY_PWD_RXPWDIFF BIT(19)
  103. +#define BM_USBPHY_PWD_RXPWD1PT1 BIT(18)
  104. +#define BM_USBPHY_PWD_RXPWDENV BIT(17)
  105. +#define BM_USBPHY_PWD_TXPWDV2I BIT(12)
  106. +#define BM_USBPHY_PWD_TXPWDIBIAS BIT(11)
  107. +#define BM_USBPHY_PWD_TXPWDFS BIT(10)
  108. +
  109. #define BM_USBPHY_CTRL_SFTRST BIT(31)
  110. #define BM_USBPHY_CTRL_CLKGATE BIT(30)
  111. #define BM_USBPHY_CTRL_ENUTMILEVEL3 BIT(15)
  112. @@ -43,14 +53,33 @@ struct mxs_phy {
  113.  
  114. static void mxs_phy_hw_init(struct mxs_phy *mxs_phy)
  115. {
  116. + int reset_sts;
  117. void __iomem *base = mxs_phy->phy.io_priv;
  118.  
  119. - stmp_reset_block(base + HW_USBPHY_CTRL);
  120. -
  121. - /* Power up the PHY */
  122. - writel_relaxed(0, base + HW_USBPHY_PWD);
  123. + /* Use global device reset function. Side effect of this
  124. + is to soft reset USBPHY_PWD, USBPHY_TX, USBPHY_RX,
  125. + and USBPHY_CTRL registers. */
  126. + reset_sts = stmp_reset_block(base + HW_USBPHY_CTRL);
  127. + if (reset_sts) {
  128. + dev_err(mxs_phy->phy.dev, "USB PHY reset failed!\n");
  129. + }
  130.  
  131. - /* enable FS/LS device */
  132. + /* Enable the PHY clock after reset. */
  133. + writel_relaxed(BM_USBPHY_CTRL_SFTRST |
  134. + BM_USBPHY_CTRL_CLKGATE,
  135. + base + HW_USBPHY_CTRL_CLR);
  136. +
  137. + /* Power up the PHY after reset. */
  138. + writel_relaxed(BM_USBPHY_PWD_RXPWDRX |
  139. + BM_USBPHY_PWD_RXPWDIFF |
  140. + BM_USBPHY_PWD_RXPWD1PT1 |
  141. + BM_USBPHY_PWD_RXPWDENV |
  142. + BM_USBPHY_PWD_TXPWDV2I |
  143. + BM_USBPHY_PWD_TXPWDIBIAS |
  144. + BM_USBPHY_PWD_TXPWDFS,
  145. + base + HW_USBPHY_PWD_CLR);
  146. +
  147. + /* Enable FS/LS device. Not supported on i.MX23. */
  148. writel_relaxed(BM_USBPHY_CTRL_ENUTMILEVEL2 |
  149. BM_USBPHY_CTRL_ENUTMILEVEL3,
  150. base + HW_USBPHY_CTRL_SET);
  151. @@ -70,6 +99,17 @@ static void mxs_phy_shutdown(struct usb_phy *phy)
  152. {
  153. struct mxs_phy *mxs_phy = to_mxs_phy(phy);
  154.  
  155. + /* Power down USB receivers and transmitters. */
  156. + writel_relaxed(BM_USBPHY_PWD_RXPWDRX |
  157. + BM_USBPHY_PWD_RXPWDIFF |
  158. + BM_USBPHY_PWD_RXPWD1PT1 |
  159. + BM_USBPHY_PWD_RXPWDENV |
  160. + BM_USBPHY_PWD_TXPWDV2I |
  161. + BM_USBPHY_PWD_TXPWDIBIAS |
  162. + BM_USBPHY_PWD_TXPWDFS,
  163. + phy->io_priv + HW_USBPHY_PWD_SET);
  164. +
  165. + /* Disable clock. */
  166. writel_relaxed(BM_USBPHY_CTRL_CLKGATE,
  167. phy->io_priv + HW_USBPHY_CTRL_SET);
  168.  
  169. @@ -81,8 +121,6 @@ static int mxs_phy_on_connect(struct usb_phy *phy, int port)
  170. dev_dbg(phy->dev, "Connect on port %d\n", port);
  171.  
  172. mxs_phy_hw_init(to_mxs_phy(phy));
  173. - writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT,
  174. - phy->io_priv + HW_USBPHY_CTRL_SET);
  175.  
  176. return 0;
  177. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement