0023-NET-PHY-add-led-support-for-intel-xway.patch 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. From 0a63ab263725c427051a8bbaa0732b749627da27 Mon Sep 17 00:00:00 2001
  2. From: John Crispin <[email protected]>
  3. Date: Thu, 7 Aug 2014 18:15:36 +0200
  4. Subject: [PATCH 23/36] NET: PHY: adds driver for lantiq PHY11G
  5. Signed-off-by: John Crispin <[email protected]>
  6. ---
  7. drivers/net/phy/Kconfig | 5 +
  8. drivers/net/phy/Makefile | 1 +
  9. drivers/net/phy/lantiq.c | 231 ++++++++++++++++++++++++++++++++++++++++++++++
  10. 3 files changed, 237 insertions(+)
  11. create mode 100644 drivers/net/phy/lantiq.c
  12. --- a/drivers/net/phy/intel-xway.c
  13. +++ b/drivers/net/phy/intel-xway.c
  14. @@ -152,6 +152,51 @@
  15. #define PHY_ID_PHY11G_VR9 0xD565A409
  16. #define PHY_ID_PHY22F_VR9 0xD565A419
  17. +#if IS_ENABLED(CONFIG_OF_MDIO)
  18. +static int vr9_gphy_of_reg_init(struct phy_device *phydev)
  19. +{
  20. + u32 tmp;
  21. +
  22. + /* store the led values if one was passed by the devicetree */
  23. + if (!of_property_read_u32(phydev->mdio.dev.of_node, "lantiq,ledch", &tmp))
  24. + phy_write_mmd(phydev, MDIO_MMD_VEND2, XWAY_MMD_LEDCH, tmp);
  25. +
  26. + if (!of_property_read_u32(phydev->mdio.dev.of_node, "lantiq,ledcl", &tmp))
  27. + phy_write_mmd(phydev, MDIO_MMD_VEND2, XWAY_MMD_LEDCL, tmp);
  28. +
  29. + if (!of_property_read_u32(phydev->mdio.dev.of_node, "lantiq,led0h", &tmp))
  30. + phy_write_mmd(phydev, MDIO_MMD_VEND2, XWAY_MMD_LED0H, tmp);
  31. +
  32. + if (!of_property_read_u32(phydev->mdio.dev.of_node, "lantiq,led0l", &tmp))
  33. + phy_write_mmd(phydev, MDIO_MMD_VEND2, XWAY_MMD_LED0L, tmp);
  34. +
  35. + if (!of_property_read_u32(phydev->mdio.dev.of_node, "lantiq,led1h", &tmp))
  36. + phy_write_mmd(phydev, MDIO_MMD_VEND2, XWAY_MMD_LED1H, tmp);
  37. +
  38. + if (!of_property_read_u32(phydev->mdio.dev.of_node, "lantiq,led1l", &tmp))
  39. + phy_write_mmd(phydev, MDIO_MMD_VEND2, XWAY_MMD_LED1L, tmp);
  40. +
  41. + if (!of_property_read_u32(phydev->mdio.dev.of_node, "lantiq,led2h", &tmp))
  42. + phy_write_mmd(phydev, MDIO_MMD_VEND2, XWAY_MMD_LED3H, tmp);
  43. +
  44. + if (!of_property_read_u32(phydev->mdio.dev.of_node, "lantiq,led2l", &tmp))
  45. + phy_write_mmd(phydev, MDIO_MMD_VEND2, XWAY_MMD_LED3L, tmp);
  46. +
  47. + if (!of_property_read_u32(phydev->mdio.dev.of_node, "lantiq,led3h", &tmp))
  48. + phy_write_mmd(phydev, MDIO_MMD_VEND2, XWAY_MMD_LED3H, tmp);
  49. +
  50. + if (!of_property_read_u32(phydev->mdio.dev.of_node, "lantiq,led3l", &tmp))
  51. + phy_write_mmd(phydev, MDIO_MMD_VEND2, XWAY_MMD_LED3L, tmp);
  52. +
  53. + return 0;
  54. +}
  55. +#else
  56. +static int vr9_gphy_of_reg_init(struct phy_device *phydev)
  57. +{
  58. + return 0;
  59. +}
  60. +#endif /* CONFIG_OF_MDIO */
  61. +
  62. static int xway_gphy_config_init(struct phy_device *phydev)
  63. {
  64. int err;
  65. @@ -190,6 +235,7 @@ static int xway_gphy_config_init(struct
  66. phy_write_mmd(phydev, MDIO_MMD_VEND2, XWAY_MMD_LED2H, ledxh);
  67. phy_write_mmd(phydev, MDIO_MMD_VEND2, XWAY_MMD_LED2L, ledxl);
  68. + vr9_gphy_of_reg_init(phydev);
  69. return 0;
  70. }
  71. --- /dev/null
  72. +++ b/Documentation/devicetree/bindings/phy/phy-lanitq.txt
  73. @@ -0,0 +1,216 @@
  74. +Lanitq PHY binding
  75. +============================================
  76. +
  77. +This devicetree binding controls the lantiq ethernet phys led functionality.
  78. +
  79. +Example:
  80. + mdio@0 {
  81. + #address-cells = <1>;
  82. + #size-cells = <0>;
  83. + compatible = "lantiq,xrx200-mdio";
  84. + phy5: ethernet-phy@5 {
  85. + reg = <0x1>;
  86. + compatible = "lantiq,phy11g", "ethernet-phy-ieee802.3-c22";
  87. + };
  88. + phy11: ethernet-phy@11 {
  89. + reg = <0x11>;
  90. + compatible = "lantiq,phy22f", "ethernet-phy-ieee802.3-c22";
  91. + lantiq,led2h = <0x00>;
  92. + lantiq,led2l = <0x03>;
  93. + };
  94. + phy12: ethernet-phy@12 {
  95. + reg = <0x12>;
  96. + compatible = "lantiq,phy22f", "ethernet-phy-ieee802.3-c22";
  97. + lantiq,led1h = <0x00>;
  98. + lantiq,led1l = <0x03>;
  99. + };
  100. + phy13: ethernet-phy@13 {
  101. + reg = <0x13>;
  102. + compatible = "lantiq,phy22f", "ethernet-phy-ieee802.3-c22";
  103. + lantiq,led2h = <0x00>;
  104. + lantiq,led2l = <0x03>;
  105. + };
  106. + phy14: ethernet-phy@14 {
  107. + reg = <0x14>;
  108. + compatible = "lantiq,phy22f", "ethernet-phy-ieee802.3-c22";
  109. + lantiq,led1h = <0x00>;
  110. + lantiq,led1l = <0x03>;
  111. + };
  112. + };
  113. +
  114. +Register Description
  115. +============================================
  116. +
  117. +LEDCH:
  118. +
  119. +Name Hardware Reset Value
  120. +LEDCH 0x00C5
  121. +
  122. +| 15 | | | | | | | 8 |
  123. +=========================================
  124. +| RES |
  125. +=========================================
  126. +
  127. +| 7 | | | | | | | 0 |
  128. +=========================================
  129. +| FBF | SBF |RES | NACS |
  130. +=========================================
  131. +
  132. +Field Bits Type Description
  133. +FBF 7:6 RW Fast Blink Frequency
  134. + ---
  135. + 0x0 (00b) F02HZ 2 Hz blinking frequency
  136. + 0x1 (01b) F04HZ 4 Hz blinking frequency
  137. + 0x2 (10b) F08HZ 8 Hz blinking frequency
  138. + 0x3 (11b) F16HZ 16 Hz blinking frequency
  139. +
  140. +SBF 5:4 RW Slow Blink Frequency
  141. + ---
  142. + 0x0 (00b) F02HZ 2 Hz blinking frequency
  143. + 0x1 (01b) F04HZ 4 Hz blinking frequency
  144. + 0x2 (10b) F08HZ 8 Hz blinking frequency
  145. + 0x3 (11b) F16HZ 16 Hz blinking frequency
  146. +
  147. +NACS 2:0 RW Inverse of Scan Function
  148. + ---
  149. + 0x0 (000b) NONE No Function
  150. + 0x1 (001b) LINK Complex function enabled when link is up
  151. + 0x2 (010b) PDOWN Complex function enabled when device is powered-down
  152. + 0x3 (011b) EEE Complex function enabled when device is in EEE mode
  153. + 0x4 (100b) ANEG Complex function enabled when auto-negotiation is running
  154. + 0x5 (101b) ABIST Complex function enabled when analog self-test is running
  155. + 0x6 (110b) CDIAG Complex function enabled when cable diagnostics are running
  156. + 0x7 (111b) TEST Complex function enabled when test mode is running
  157. +
  158. +LEDCL:
  159. +
  160. +Name Hardware Reset Value
  161. +LEDCL 0x0067
  162. +
  163. +| 15 | | | | | | | 8 |
  164. +=========================================
  165. +| RES |
  166. +=========================================
  167. +
  168. +| 7 | | | | | | | 0 |
  169. +=========================================
  170. +|RES | SCAN |RES | CBLINK |
  171. +=========================================
  172. +
  173. +Field Bits Type Description
  174. +SCAN 6:4 RW Complex Scan Configuration
  175. + ---
  176. + 000 B NONE No Function
  177. + 001 B LINK Complex function enabled when link is up
  178. + 010 B PDOWN Complex function enabled when device is powered-down
  179. + 011 B EEE Complex function enabled when device is in EEE mode
  180. + 100 B ANEG Complex function enabled when auto-negotiation is running
  181. + 101 B ABIST Complex function enabled when analog self-test is running
  182. + 110 B CDIAG Complex function enabled when cable diagnostics are running
  183. + 111 B TEST Complex function enabled when test mode is running
  184. +
  185. +CBLINK 2:0 RW Complex Blinking Configuration
  186. + ---
  187. + 000 B NONE No Function
  188. + 001 B LINK Complex function enabled when link is up
  189. + 010 B PDOWN Complex function enabled when device is powered-down
  190. + 011 B EEE Complex function enabled when device is in EEE mode
  191. + 100 B ANEG Complex function enabled when auto-negotiation is running
  192. + 101 B ABIST Complex function enabled when analog self-test is running
  193. + 110 B CDIAG Complex function enabled when cable diagnostics are running
  194. + 111 B TEST Complex function enabled when test mode is running
  195. +
  196. +LEDxH:
  197. +
  198. +Name Hardware Reset Value
  199. +LED0H 0x0070
  200. +LED1H 0x0020
  201. +LED2H 0x0040
  202. +LED3H 0x0040
  203. +
  204. +| 15 | | | | | | | 8 |
  205. +=========================================
  206. +| RES |
  207. +=========================================
  208. +
  209. +| 7 | | | | | | | 0 |
  210. +=========================================
  211. +| CON | BLINKF |
  212. +=========================================
  213. +
  214. +Field Bits Type Description
  215. +CON 7:4 RW Constant On Configuration
  216. + ---
  217. + 0x0 (0000b) NONE LED does not light up constantly
  218. + 0x1 (0001b) LINK10 LED is on when link is 10 Mbit/s
  219. + 0x2 (0010b) LINK100 LED is on when link is 100 Mbit/s
  220. + 0x3 (0011b) LINK10X LED is on when link is 10/100 Mbit/s
  221. + 0x4 (0100b) LINK1000 LED is on when link is 1000 Mbit/s
  222. + 0x5 (0101b) LINK10_0 LED is on when link is 10/1000 Mbit/s
  223. + 0x6 (0110b) LINK100X LED is on when link is 100/1000 Mbit/s
  224. + 0x7 (0111b) LINK10XX LED is on when link is 10/100/1000 Mbit/s
  225. + 0x8 (1000b) PDOWN LED is on when device is powered-down
  226. + 0x9 (1001b) EEE LED is on when device is in EEE mode
  227. + 0xA (1010b) ANEG LED is on when auto-negotiation is running
  228. + 0xB (1011b) ABIST LED is on when analog self-test is running
  229. + 0xC (1100b) CDIAG LED is on when cable diagnostics are running
  230. +
  231. +BLINKF 3:0 RW Fast Blinking Configuration
  232. + ---
  233. + 0x0 (0000b) NONE No Blinking
  234. + 0x1 (0001b) LINK10 Blink when link is 10 Mbit/s
  235. + 0x2 (0010b) LINK100 Blink when link is 100 Mbit/s
  236. + 0x3 (0011b) LINK10X Blink when link is 10/100 Mbit/s
  237. + 0x4 (0100b) LINK1000 Blink when link is 1000 Mbit/s
  238. + 0x5 (0101b) LINK10_0 Blink when link is 10/1000 Mbit/s
  239. + 0x6 (0110b) LINK100X Blink when link is 100/1000 Mbit/s
  240. + 0x7 (0111b) LINK10XX Blink when link is 10/100/1000 Mbit/s
  241. + 0x8 (1000b) PDOWN Blink when device is powered-down
  242. + 0x9 (1001b) EEE Blink when device is in EEE mode
  243. + 0xA (1010b) ANEG Blink when auto-negotiation is running
  244. + 0xB (1011b) ABIST Blink when analog self-test is running
  245. + 0xC (1100b) CDIAG Blink when cable diagnostics are running
  246. +
  247. +LEDxL:
  248. +
  249. +Name Hardware Reset Value
  250. +LED0L 0x0003
  251. +LED1L 0x0000
  252. +LED2L 0x0000
  253. +LED3L 0x0020
  254. +
  255. +| 15 | | | | | | | 8 |
  256. +=========================================
  257. +| RES |
  258. +=========================================
  259. +
  260. +| 7 | | | | | | | 0 |
  261. +=========================================
  262. +| BLINKS | PULSE |
  263. +=========================================
  264. +
  265. +Field Bits Type Description
  266. +BLINKS 7:4 RW Slow Blinkin Configuration
  267. + ---
  268. + 0x0 (0000b) NONE No Blinking
  269. + 0x1 (0001b) LINK10 Blink when link is 10 Mbit/s
  270. + 0x2 (0010b) LINK100 Blink when link is 100 Mbit/s
  271. + 0x3 (0011b) LINK10X Blink when link is 10/100 Mbit/s
  272. + 0x4 (0100b) LINK1000 Blink when link is 1000 Mbit/s
  273. + 0x5 (0101b) LINK10_0 Blink when link is 10/1000 Mbit/s
  274. + 0x6 (0110b) LINK100X Blink when link is 100/1000 Mbit/s
  275. + 0x7 (0111b) LINK10XX Blink when link is 10/100/1000 Mbit/s
  276. + 0x8 (1000b) PDOWN Blink when device is powered-down
  277. + 0x9 (1001b) EEE Blink when device is in EEE mode
  278. + 0xA (1010b) ANEG Blink when auto-negotiation is running
  279. + 0xB (1011b) ABIST Blink when analog self-test is running
  280. + 0xC (1100b) CDIAG Blink when cable diagnostics are runningning
  281. +
  282. +PULSE 3:0 RW Pulsing Configuration
  283. + The pulse field is a mask field by which certain events can be combined
  284. + ---
  285. + 0x0 (0000b) NONE No pulsing
  286. + 0x1 (0001b) TXACT Transmit activity
  287. + 0x2 (0010b) RXACT Receive activity
  288. + 0x4 (0100b) COL Collision
  289. + 0x8 (1000b) RES Reserved