realtek.yaml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
  2. %YAML 1.2
  3. ---
  4. $id: http://devicetree.org/schemas/net/dsa/realtek.yaml#
  5. $schema: http://devicetree.org/meta-schemas/core.yaml#
  6. title: Realtek switches for unmanaged switches
  7. allOf:
  8. - $ref: dsa.yaml#/$defs/ethernet-ports
  9. maintainers:
  10. - Linus Walleij <linusw@kernel.org>
  11. description:
  12. Realtek advertises these chips as fast/gigabit switches or unmanaged
  13. switches. They can be controlled using different interfaces, like SMI,
  14. MDIO or SPI.
  15. The SMI "Simple Management Interface" is a two-wire protocol using
  16. bit-banged GPIO that while it reuses the MDIO lines MCK and MDIO does
  17. not use the MDIO protocol. This binding defines how to specify the
  18. SMI-based Realtek devices. The realtek-smi driver is a platform driver
  19. and it must be inserted inside a platform node.
  20. The MDIO-connected switches use MDIO protocol to access their registers.
  21. The realtek-mdio driver is an MDIO driver and it must be inserted inside
  22. an MDIO node.
  23. The compatible string is only used to identify which (silicon) family the
  24. switch belongs to. Roughly speaking, a family is any set of Realtek switches
  25. whose chip identification register(s) have a common location and semantics.
  26. The different models in a given family can be automatically disambiguated by
  27. parsing the chip identification register(s) according to the given family,
  28. avoiding the need for a unique compatible string for each model.
  29. properties:
  30. compatible:
  31. enum:
  32. - realtek,rtl8365mb
  33. - realtek,rtl8366rb
  34. description: |
  35. realtek,rtl8365mb:
  36. Use with models RTL8363NB, RTL8363NB-VB, RTL8363SC, RTL8363SC-VB,
  37. RTL8364NB, RTL8364NB-VB, RTL8365MB, RTL8366SC, RTL8367RB-VB, RTL8367S,
  38. RTL8367SB, RTL8370MB, RTL8310SR
  39. realtek,rtl8366rb:
  40. Use with models RTL8366RB, RTL8366S
  41. mdc-gpios:
  42. description: GPIO line for the MDC clock line.
  43. maxItems: 1
  44. mdio-gpios:
  45. description: GPIO line for the MDIO data line.
  46. maxItems: 1
  47. reset-gpios:
  48. description: GPIO to be used to reset the whole device
  49. maxItems: 1
  50. resets:
  51. maxItems: 1
  52. realtek,disable-leds:
  53. type: boolean
  54. description: |
  55. if the LED drivers are not used in the hardware design,
  56. this will disable them so they are not turned on
  57. and wasting power.
  58. interrupt-controller:
  59. type: object
  60. additionalProperties: false
  61. description: |
  62. This defines an interrupt controller with an IRQ line (typically
  63. a GPIO) that will demultiplex and handle the interrupt from the single
  64. interrupt line coming out of one of the Realtek switch chips. It most
  65. importantly provides link up/down interrupts to the PHY blocks inside
  66. the ASIC.
  67. properties:
  68. interrupt-controller: true
  69. interrupts:
  70. maxItems: 1
  71. description:
  72. A single IRQ line from the switch, either active LOW or HIGH
  73. '#address-cells':
  74. const: 0
  75. '#interrupt-cells':
  76. const: 1
  77. required:
  78. - interrupt-controller
  79. - '#address-cells'
  80. - '#interrupt-cells'
  81. mdio:
  82. $ref: /schemas/net/mdio.yaml#
  83. unevaluatedProperties: false
  84. properties:
  85. compatible:
  86. const: realtek,smi-mdio
  87. if:
  88. required:
  89. - reg
  90. then:
  91. $ref: /schemas/spi/spi-peripheral-props.yaml#
  92. not:
  93. required:
  94. - mdc-gpios
  95. - mdio-gpios
  96. - mdio
  97. properties:
  98. mdc-gpios: false
  99. mdio-gpios: false
  100. mdio: false
  101. else:
  102. required:
  103. - mdc-gpios
  104. - mdio-gpios
  105. - mdio
  106. required:
  107. - compatible
  108. # - mdc-gpios
  109. # - mdio-gpios
  110. # - reset-gpios
  111. # - mdio
  112. unevaluatedProperties: false
  113. examples:
  114. - |
  115. #include <dt-bindings/gpio/gpio.h>
  116. #include <dt-bindings/interrupt-controller/irq.h>
  117. platform {
  118. ethernet-switch {
  119. compatible = "realtek,rtl8366rb";
  120. /* 22 = MDIO (has input reads), 21 = MDC (clock, output only) */
  121. mdc-gpios = <&gpio0 21 GPIO_ACTIVE_HIGH>;
  122. mdio-gpios = <&gpio0 22 GPIO_ACTIVE_HIGH>;
  123. reset-gpios = <&gpio0 14 GPIO_ACTIVE_LOW>;
  124. switch_intc1: interrupt-controller {
  125. /* GPIO 15 provides the interrupt */
  126. interrupt-parent = <&gpio0>;
  127. interrupts = <15 IRQ_TYPE_LEVEL_LOW>;
  128. interrupt-controller;
  129. #address-cells = <0>;
  130. #interrupt-cells = <1>;
  131. };
  132. ethernet-ports {
  133. #address-cells = <1>;
  134. #size-cells = <0>;
  135. ethernet-port@0 {
  136. reg = <0>;
  137. label = "lan0";
  138. phy-handle = <&phy0>;
  139. };
  140. ethernet-port@1 {
  141. reg = <1>;
  142. label = "lan1";
  143. phy-handle = <&phy1>;
  144. };
  145. ethernet-port@2 {
  146. reg = <2>;
  147. label = "lan2";
  148. phy-handle = <&phy2>;
  149. };
  150. ethernet-port@3 {
  151. reg = <3>;
  152. label = "lan3";
  153. phy-handle = <&phy3>;
  154. };
  155. ethernet-port@4 {
  156. reg = <4>;
  157. label = "wan";
  158. phy-handle = <&phy4>;
  159. };
  160. ethernet-port@5 {
  161. reg = <5>;
  162. ethernet = <&gmac0>;
  163. phy-mode = "rgmii";
  164. fixed-link {
  165. speed = <1000>;
  166. full-duplex;
  167. };
  168. };
  169. };
  170. mdio {
  171. compatible = "realtek,smi-mdio";
  172. #address-cells = <1>;
  173. #size-cells = <0>;
  174. phy0: ethernet-phy@0 {
  175. reg = <0>;
  176. interrupt-parent = <&switch_intc1>;
  177. interrupts = <0>;
  178. };
  179. phy1: ethernet-phy@1 {
  180. reg = <1>;
  181. interrupt-parent = <&switch_intc1>;
  182. interrupts = <1>;
  183. };
  184. phy2: ethernet-phy@2 {
  185. reg = <2>;
  186. interrupt-parent = <&switch_intc1>;
  187. interrupts = <2>;
  188. };
  189. phy3: ethernet-phy@3 {
  190. reg = <3>;
  191. interrupt-parent = <&switch_intc1>;
  192. interrupts = <3>;
  193. };
  194. phy4: ethernet-phy@4 {
  195. reg = <4>;
  196. interrupt-parent = <&switch_intc1>;
  197. interrupts = <12>;
  198. };
  199. };
  200. };
  201. };
  202. - |
  203. #include <dt-bindings/gpio/gpio.h>
  204. #include <dt-bindings/interrupt-controller/irq.h>
  205. platform {
  206. ethernet-switch {
  207. compatible = "realtek,rtl8365mb";
  208. mdc-gpios = <&gpio1 16 GPIO_ACTIVE_HIGH>;
  209. mdio-gpios = <&gpio1 17 GPIO_ACTIVE_HIGH>;
  210. reset-gpios = <&gpio5 0 GPIO_ACTIVE_LOW>;
  211. switch_intc2: interrupt-controller {
  212. interrupt-parent = <&gpio5>;
  213. interrupts = <1 IRQ_TYPE_LEVEL_LOW>;
  214. interrupt-controller;
  215. #address-cells = <0>;
  216. #interrupt-cells = <1>;
  217. };
  218. ethernet-ports {
  219. #address-cells = <1>;
  220. #size-cells = <0>;
  221. ethernet-port@0 {
  222. reg = <0>;
  223. label = "swp0";
  224. phy-handle = <&ethphy0>;
  225. };
  226. ethernet-port@1 {
  227. reg = <1>;
  228. label = "swp1";
  229. phy-handle = <&ethphy1>;
  230. };
  231. ethernet-port@2 {
  232. reg = <2>;
  233. label = "swp2";
  234. phy-handle = <&ethphy2>;
  235. };
  236. ethernet-port@3 {
  237. reg = <3>;
  238. label = "swp3";
  239. phy-handle = <&ethphy3>;
  240. };
  241. ethernet-port@6 {
  242. reg = <6>;
  243. ethernet = <&fec1>;
  244. phy-mode = "rgmii";
  245. tx-internal-delay-ps = <2000>;
  246. rx-internal-delay-ps = <2000>;
  247. fixed-link {
  248. speed = <1000>;
  249. full-duplex;
  250. pause;
  251. };
  252. };
  253. };
  254. mdio {
  255. compatible = "realtek,smi-mdio";
  256. #address-cells = <1>;
  257. #size-cells = <0>;
  258. ethphy0: ethernet-phy@0 {
  259. reg = <0>;
  260. interrupt-parent = <&switch_intc2>;
  261. interrupts = <0>;
  262. };
  263. ethphy1: ethernet-phy@1 {
  264. reg = <1>;
  265. interrupt-parent = <&switch_intc2>;
  266. interrupts = <1>;
  267. };
  268. ethphy2: ethernet-phy@2 {
  269. reg = <2>;
  270. interrupt-parent = <&switch_intc2>;
  271. interrupts = <2>;
  272. };
  273. ethphy3: ethernet-phy@3 {
  274. reg = <3>;
  275. interrupt-parent = <&switch_intc2>;
  276. interrupts = <3>;
  277. };
  278. };
  279. };
  280. };
  281. - |
  282. #include <dt-bindings/gpio/gpio.h>
  283. #include <dt-bindings/interrupt-controller/irq.h>
  284. mdio {
  285. #address-cells = <1>;
  286. #size-cells = <0>;
  287. ethernet-switch@29 {
  288. compatible = "realtek,rtl8365mb";
  289. reg = <29>;
  290. reset-gpios = <&gpio2 20 GPIO_ACTIVE_LOW>;
  291. switch_intc3: interrupt-controller {
  292. interrupt-parent = <&gpio0>;
  293. interrupts = <11 IRQ_TYPE_EDGE_FALLING>;
  294. interrupt-controller;
  295. #address-cells = <0>;
  296. #interrupt-cells = <1>;
  297. };
  298. ethernet-ports {
  299. #address-cells = <1>;
  300. #size-cells = <0>;
  301. ethernet-port@0 {
  302. reg = <0>;
  303. label = "lan4";
  304. };
  305. ethernet-port@1 {
  306. reg = <1>;
  307. label = "lan3";
  308. };
  309. ethernet-port@2 {
  310. reg = <2>;
  311. label = "lan2";
  312. };
  313. ethernet-port@3 {
  314. reg = <3>;
  315. label = "lan1";
  316. };
  317. ethernet-port@4 {
  318. reg = <4>;
  319. label = "wan";
  320. };
  321. ethernet-port@7 {
  322. reg = <7>;
  323. ethernet = <&ethernet>;
  324. phy-mode = "rgmii";
  325. tx-internal-delay-ps = <2000>;
  326. rx-internal-delay-ps = <0>;
  327. fixed-link {
  328. speed = <1000>;
  329. full-duplex;
  330. };
  331. };
  332. };
  333. };
  334. };