0041-ramips-add-support-for-Ubiquiti-EdgeRouter-X-SFP.patch 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. From: Sven Roederer <devel-sven@geroedel.de>
  2. Date: Mon, 29 May 2017 11:24:49 +0200
  3. Subject: ramips: add support for Ubiquiti EdgeRouter X-SFP
  4. This patch adds support for the Ubiquiti EdgeRouter X-SFP and
  5. improves support for the EdgeRouter X (PoE-passthrough).
  6. Specification:
  7. - SoC: MediaTek MT7621AT
  8. - Flash: 256 MiB
  9. - RAM: 265 MiB
  10. - Ethernet: 5 x LAN (1000 Mbps)
  11. - UART: 1 x UART on PCB (3.3V, RX, TX, GND) - 57600 8N1
  12. - EdgeRouter X:
  13. - 1 x PoE-Passtrough (Eth4)
  14. - powered by Wallwart or passive PoE
  15. - EdgeRouter X-SFP:
  16. - 5 x PoE-Out (24V, passive)
  17. - 1 x SFP (unknown status)
  18. - powered by Wallwart (24V)
  19. Doesn't work:
  20. * SoC has crypto engine but no open driver.
  21. * SoC has nat acceleration, but no open driver.
  22. * This router has 2MB spi flash soldered in but MT
  23. nand/spi drivers do not support pin sharing,
  24. so it is not accessable and disabled. Stock
  25. firmware could read it and it was empty.
  26. Installation
  27. via vendor firmware:
  28. - build an Initrd-image (> 3MiB) and upload the factory-image
  29. - initrd can have luci-mod-failsafe
  30. - flash final firmware via LuCI / sysupgrade on rebooted system
  31. via TFTP:
  32. - stop uboot into tftp-load into option "1"
  33. - upload factory.bin image
  34. Signed-off-by: Sven Roederer <devel-sven@geroedel.de>
  35. diff --git a/target/linux/ramips/base-files/etc/board.d/02_network b/target/linux/ramips/base-files/etc/board.d/02_network
  36. index 1778dc93297136e3196ad3f74e4b3bea7535cee0..1f5c6429201ba05fc14ff09c6c562d2c114f2a63 100755
  37. --- a/target/linux/ramips/base-files/etc/board.d/02_network
  38. +++ b/target/linux/ramips/base-files/etc/board.d/02_network
  39. @@ -146,6 +146,7 @@ ramips_setup_interfaces()
  40. rb750gr3|\
  41. rt-n14u|\
  42. ubnt-erx|\
  43. + ubnt-erx-sfp|\
  44. ur-326n4g|\
  45. wrtnode|\
  46. wrtnode2p | \
  47. diff --git a/target/linux/ramips/base-files/etc/board.d/03_gpio_switches b/target/linux/ramips/base-files/etc/board.d/03_gpio_switches
  48. new file mode 100755
  49. index 0000000000000000000000000000000000000000..859dfb31f51244e69d3dce5fc80b329cb57729f3
  50. --- /dev/null
  51. +++ b/target/linux/ramips/base-files/etc/board.d/03_gpio_switches
  52. @@ -0,0 +1,25 @@
  53. +#!/bin/sh
  54. +
  55. +. /lib/functions/uci-defaults.sh
  56. +. /lib/ramips.sh
  57. +
  58. +board_config_update
  59. +
  60. +board=$(ramips_board_name)
  61. +
  62. +case "$board" in
  63. +ubnt-erx)
  64. + ucidef_add_gpio_switch "poe_passthrough" "PoE Passthrough" "0"
  65. + ;;
  66. +ubnt-erx-sfp)
  67. + ucidef_add_gpio_switch "poe_power_port0" "PoE Power Port0" "496"
  68. + ucidef_add_gpio_switch "poe_power_port1" "PoE Power Port1" "497"
  69. + ucidef_add_gpio_switch "poe_power_port2" "PoE Power Port2" "498"
  70. + ucidef_add_gpio_switch "poe_power_port3" "PoE Power Port3" "499"
  71. + ucidef_add_gpio_switch "poe_power_port4" "PoE Power Port4" "500"
  72. + ;;
  73. +esac
  74. +
  75. +board_config_flush
  76. +
  77. +exit 0
  78. diff --git a/target/linux/ramips/base-files/lib/ramips.sh b/target/linux/ramips/base-files/lib/ramips.sh
  79. index 17ada648931f16d3e85630dd341defb89ba50d6f..b1091f66b2897a19bd01d4a26a1b3647656fa62b 100755
  80. --- a/target/linux/ramips/base-files/lib/ramips.sh
  81. +++ b/target/linux/ramips/base-files/lib/ramips.sh
  82. @@ -466,6 +466,9 @@ ramips_board_detect() {
  83. *"UBNT-ERX")
  84. name="ubnt-erx"
  85. ;;
  86. + *"UBNT-ERX-SFP")
  87. + name="ubnt-erx-sfp"
  88. + ;;
  89. *"UR-326N4G")
  90. name="ur-326n4g"
  91. ;;
  92. diff --git a/target/linux/ramips/base-files/lib/upgrade/platform.sh b/target/linux/ramips/base-files/lib/upgrade/platform.sh
  93. index a5cca2080d3b96cef92286b1b15f4f8832d9f8c5..d3efc2dd37ed855a1c0e966e448b67ae73324d5f 100755
  94. --- a/target/linux/ramips/base-files/lib/upgrade/platform.sh
  95. +++ b/target/linux/ramips/base-files/lib/upgrade/platform.sh
  96. @@ -234,7 +234,8 @@ platform_check_image() {
  97. }
  98. return 0
  99. ;;
  100. - ubnt-erx)
  101. + ubnt-erx|\
  102. + ubnt-erx-sfp)
  103. nand_do_platform_check "$board" "$1"
  104. return $?;
  105. ;;
  106. @@ -248,7 +249,8 @@ platform_nand_pre_upgrade() {
  107. local board=$(ramips_board_name)
  108. case "$board" in
  109. - ubnt-erx)
  110. + ubnt-erx|\
  111. + ubnt-erx-sfp)
  112. platform_upgrade_ubnt_erx "$ARGV"
  113. ;;
  114. esac
  115. @@ -258,7 +260,8 @@ platform_do_upgrade() {
  116. local board=$(ramips_board_name)
  117. case "$board" in
  118. - ubnt-erx)
  119. + ubnt-erx|\
  120. + ubnt-erx-sfp)
  121. nand_do_upgrade "$ARGV"
  122. ;;
  123. *)
  124. diff --git a/target/linux/ramips/dts/UBNT-ER-e50.dtsi b/target/linux/ramips/dts/UBNT-ER-e50.dtsi
  125. new file mode 100644
  126. index 0000000000000000000000000000000000000000..b38c7194942db9f0a713fd8f707b53820d07c78e
  127. --- /dev/null
  128. +++ b/target/linux/ramips/dts/UBNT-ER-e50.dtsi
  129. @@ -0,0 +1,106 @@
  130. +#include "mt7621.dtsi"
  131. +
  132. +#include <dt-bindings/gpio/gpio.h>
  133. +#include <dt-bindings/input/input.h>
  134. +
  135. +/ {
  136. + compatible = "ubiquiti,edgerouterx";
  137. +
  138. + memory@0 {
  139. + device_type = "memory";
  140. + reg = <0x0 0x10000000>;
  141. + };
  142. +
  143. + chosen {
  144. + bootargs = "console=ttyS0,57600";
  145. + };
  146. +
  147. + gpio-keys-polled {
  148. + compatible = "gpio-keys-polled";
  149. + #address-cells = <1>;
  150. + #size-cells = <0>;
  151. + poll-interval = <20>;
  152. +
  153. + reset {
  154. + label = "reset";
  155. + gpios = <&gpio0 12 GPIO_ACTIVE_LOW>;
  156. + linux,code = <KEY_RESTART>;
  157. + };
  158. + };
  159. +};
  160. +
  161. +&ethernet {
  162. + mtd-mac-address = <&factory 0x22>;
  163. +};
  164. +
  165. +&nand {
  166. + status = "okay";
  167. +
  168. + partition@0 {
  169. + label = "u-boot";
  170. + reg = <0x0 0x80000>;
  171. + read-only;
  172. + };
  173. +
  174. + partition@80000 {
  175. + label = "u-boot-env";
  176. + reg = <0x80000 0x60000>;
  177. + read-only;
  178. + };
  179. +
  180. + factory: partition@e0000 {
  181. + label = "factory";
  182. + reg = <0xe0000 0x60000>;
  183. + };
  184. +
  185. + partition@140000 {
  186. + label = "kernel1";
  187. + reg = <0x140000 0x300000>;
  188. + };
  189. +
  190. + partition@440000 {
  191. + label = "kernel2";
  192. + reg = <0x440000 0x300000>;
  193. + };
  194. +
  195. + partition@740000 {
  196. + label = "ubi";
  197. + reg = <0x740000 0xf7c0000>;
  198. + };
  199. +};
  200. +
  201. +&pinctrl {
  202. + state_default: pinctrl0 {
  203. + gpio {
  204. + ralink,group = "uart2", "uart3", "i2c", "pcie", "rgmii2", "jtag";
  205. + ralink,function = "gpio";
  206. + };
  207. + };
  208. +};
  209. +
  210. +&spi0 {
  211. + /* This board has 2Mb spi flash soldered in and visible
  212. + from manufacturer's firmware.
  213. + But this SoC shares spi and nand pins,
  214. + and current driver does't handle this sharing well */
  215. + status = "disabled";
  216. +
  217. + m25p80@0 {
  218. + #address-cells = <1>;
  219. + #size-cells = <1>;
  220. + compatible = "jedec,spi-nor";
  221. + reg = <1>;
  222. + spi-max-frequency = <10000000>;
  223. + m25p,chunked-io = <32>;
  224. +
  225. + partition@0 {
  226. + label = "spi";
  227. + reg = <0x0 0x200000>;
  228. + read-only;
  229. + };
  230. + };
  231. +};
  232. +
  233. +&xhci {
  234. + status = "disabled";
  235. +};
  236. diff --git a/target/linux/ramips/dts/UBNT-ERX-SFP.dts b/target/linux/ramips/dts/UBNT-ERX-SFP.dts
  237. new file mode 100644
  238. index 0000000000000000000000000000000000000000..ca26d817211e5a5a20a7da926cd2aee726875780
  239. --- /dev/null
  240. +++ b/target/linux/ramips/dts/UBNT-ERX-SFP.dts
  241. @@ -0,0 +1,24 @@
  242. +/dts-v1/;
  243. +
  244. +#include "UBNT-ER-e50.dtsi"
  245. +
  246. +#include <dt-bindings/gpio/gpio.h>
  247. +
  248. +/ {
  249. + model = "UBNT-ERX-SFP";
  250. + compatible = "ubiquiti,edgerouterx-sfp";
  251. +
  252. + i2c-gpio {
  253. + compatible = "i2c-gpio";
  254. + gpios = <&gpio0 3 GPIO_ACTIVE_HIGH /* sda */
  255. + &gpio0 4 GPIO_ACTIVE_HIGH /* scl */
  256. + >;
  257. + #address-cells = <1>;
  258. + #size-cells = <0>;
  259. +
  260. + pca9555@25 {
  261. + compatible = "pca9555";
  262. + reg = <0x25>;
  263. + };
  264. + };
  265. +};
  266. diff --git a/target/linux/ramips/dts/UBNT-ERX.dts b/target/linux/ramips/dts/UBNT-ERX.dts
  267. index cf86bbb7e67b1c521c279367ee9e99fee88fae85..556d1156c352f76a94c6e39bc3b58c88f08815be 100644
  268. --- a/target/linux/ramips/dts/UBNT-ERX.dts
  269. +++ b/target/linux/ramips/dts/UBNT-ERX.dts
  270. @@ -1,108 +1,7 @@
  271. /dts-v1/;
  272. -#include "mt7621.dtsi"
  273. -
  274. -#include <dt-bindings/gpio/gpio.h>
  275. -#include <dt-bindings/input/input.h>
  276. +#include "UBNT-ER-e50.dtsi"
  277. / {
  278. model = "UBNT-ERX";
  279. -
  280. - memory@0 {
  281. - device_type = "memory";
  282. - reg = <0x0 0x10000000>;
  283. - };
  284. -
  285. - chosen {
  286. - bootargs = "console=ttyS0,57600";
  287. - };
  288. -
  289. - gpio-keys-polled {
  290. - compatible = "gpio-keys-polled";
  291. - #address-cells = <1>;
  292. - #size-cells = <0>;
  293. - poll-interval = <20>;
  294. -
  295. - reset {
  296. - label = "reset";
  297. - gpios = <&gpio0 12 GPIO_ACTIVE_LOW>;
  298. - linux,code = <KEY_RESTART>;
  299. - };
  300. - };
  301. -};
  302. -
  303. -&ethernet {
  304. - mtd-mac-address = <&factory 0x22>;
  305. -};
  306. -
  307. -&nand {
  308. - status = "okay";
  309. -
  310. - partition@0 {
  311. - label = "u-boot";
  312. - reg = <0x0 0x80000>;
  313. - read-only;
  314. - };
  315. -
  316. - partition@80000 {
  317. - label = "u-boot-env";
  318. - reg = <0x80000 0x60000>;
  319. - read-only;
  320. - };
  321. -
  322. - factory: partition@e0000 {
  323. - label = "factory";
  324. - reg = <0xe0000 0x60000>;
  325. - };
  326. -
  327. - partition@140000 {
  328. - label = "kernel1";
  329. - reg = <0x140000 0x300000>;
  330. - };
  331. -
  332. - partition@440000 {
  333. - label = "kernel2";
  334. - reg = <0x440000 0x300000>;
  335. - };
  336. -
  337. - partition@740000 {
  338. - label = "ubi";
  339. - reg = <0x740000 0xf7c0000>;
  340. - };
  341. -};
  342. -
  343. -&pinctrl {
  344. - state_default: pinctrl0 {
  345. - gpio {
  346. - ralink,group = "uart2", "uart3", "i2c", "pcie", "rgmii2", "jtag";
  347. - ralink,function = "gpio";
  348. - };
  349. - };
  350. -};
  351. -
  352. -&spi0 {
  353. - /* This board has 2Mb spi flash soldered in and visible
  354. - from manufacturer's firmware.
  355. - But this SoC shares spi and nand pins,
  356. - and current driver does't handle this sharing well */
  357. - status = "disabled";
  358. -
  359. - m25p80@0 {
  360. - #address-cells = <1>;
  361. - #size-cells = <1>;
  362. - compatible = "jedec,spi-nor";
  363. - reg = <1>;
  364. - spi-max-frequency = <10000000>;
  365. - m25p,chunked-io = <32>;
  366. -
  367. - partition@0 {
  368. - label = "spi";
  369. - reg = <0x0 0x200000>;
  370. - read-only;
  371. - };
  372. - };
  373. -};
  374. -
  375. -&xhci {
  376. - status = "disabled";
  377. };
  378. diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk
  379. index 15ea9a13b6310b1454b5b3b92cd8ed30ee6255b3..8218bea84410536151a216cd2cc0300369ad977a 100644
  380. --- a/target/linux/ramips/image/mt7621.mk
  381. +++ b/target/linux/ramips/image/mt7621.mk
  382. @@ -144,6 +144,19 @@ define Device/ubnt-erx
  383. endef
  384. TARGET_DEVICES += ubnt-erx
  385. +define Device/ubnt-erx-sfp
  386. + DTS := UBNT-ERX-SFP
  387. + FILESYSTEMS := squashfs
  388. + KERNEL_SIZE := 3145728
  389. + KERNEL := $(KERNEL_DTB) | uImage lzma
  390. + IMAGES := sysupgrade.tar
  391. + KERNEL_INITRAMFS := $$(KERNEL) | ubnt-erx-factory-image $(KDIR)/tmp/$$(KERNEL_INITRAMFS_PREFIX)-factory.tar
  392. + IMAGE/sysupgrade.tar := sysupgrade-tar | append-metadata
  393. + DEVICE_TITLE := Ubiquiti EdgeRouter X-SFP
  394. + DEVICE_PACKAGES := -kmod-mt76 -kmod-rt2x00-lib -kmod-mac80211 -kmod-cfg80211 -wpad-mini -iwinfo kmod-i2c-algo-pca kmod-gpio-pca953x kmod-i2c-gpio-custom
  395. +endef
  396. +TARGET_DEVICES += ubnt-erx-sfp
  397. +
  398. define Device/vr500
  399. DTS := VR500
  400. IMAGE_SIZE := 66453504