ar71xx: add support for the Airtight C-60
[openwrt/openwrt.git] / target / linux / ar71xx / base-files / lib / ar71xx.sh
index 56b59474b18e8e56449d2a731bfa1e337d5dc79e..940c1c95de45456cf78d83c9f4baa4a9417eeeff 100755 (executable)
@@ -64,6 +64,39 @@ wndr3700_board_detect() {
        AR71XX_MODEL="$machine"
 }
 
+ubnt_get_mtd_part_magic() {
+       ar71xx_get_mtd_offset_size_format EEPROM 4118 2 %02x
+}
+
+ubnt_xm_board_detect() {
+       local model
+       local magic
+
+       magic="$(ubnt_get_mtd_part_magic)"
+       case ${magic:0:3} in
+               "e00"|\
+               "e01"|\
+               "e80")  # Different revisions of the NanoStation?
+                       model="Ubiquiti NanoStation M"
+                       ;;
+               "e0a")
+                       model="Ubiquiti NanoStation loco M"
+                       ;;
+               "e1b")  # Rocket M5 untested
+                       model="Ubiquiti Rocket M"
+                       ;;
+               "e20"|\
+               "e2d")  # Bullet M Ti
+                       model="Ubiquiti Bullet M"
+                       ;;
+               "e30")
+                       model="Ubiquiti PicoStation M"
+                       ;;
+       esac
+
+       [ -z "$model" ] || AR71XX_MODEL="${model}${magic:3:1}"
+}
+
 cybertan_get_hw_magic() {
        local part
 
@@ -73,6 +106,15 @@ cybertan_get_hw_magic() {
        dd bs=8 count=1 skip=0 if=$part 2>/dev/null | hexdump -v -n 8 -e '1/1 "%02x"'
 }
 
+dir505_board_detect() {
+       local dev=$(find_mtd_part 'mac')
+       [ -z "$dev" ] && return
+
+       # The revision is stored at the beginning of the "mac" partition
+       local rev="$(LC_CTYPE=C awk -v 'FS=[^[:print:]]' '{print $1; exit}' $dev)"
+       AR71XX_MODEL="D-Link DIR-505 rev. $rev"
+}
+
 tplink_get_hwid() {
        local part
 
@@ -271,7 +313,7 @@ tplink_board_detect() {
                model="TP-Link TL-WDR6500"
                ;;
        "453000"*)
-               model="MERCURY MW4530R"
+               model="Mercury MW4530R"
                ;;
        "934100"*)
                model="NC-LINK SMART-300"
@@ -440,6 +482,9 @@ ar71xx_board_detect() {
        *C-55)
                name="c-55"
                ;;
+       *C-60)
+               name="c-60"
+               ;;
        *CAP4200AG)
                name="cap4200ag"
                ;;
@@ -471,6 +516,7 @@ ar71xx_board_detect() {
                ;;
        *"DIR-505 rev. A1")
                name="dir-505-a1"
+               dir505_board_detect
                ;;
        *"DIR-600 rev. A1")
                name="dir-600-a1"
@@ -493,6 +539,9 @@ ar71xx_board_detect() {
        *"DIR-835 rev. A1")
                name="dir-835-a1"
                ;;
+       *"DIR-869 rev. A1")
+               name="dir-869-a1"
+               ;;
        *"dLAN Hotspot")
                name="dlan-hotspot"
                ;;
@@ -559,12 +608,14 @@ ar71xx_board_detect() {
                ;;
        *"Bullet M")
                name="bullet-m"
+               ubnt_xm_board_detect
                ;;
        *"Loco M XW")
                name="loco-m-xw"
                ;;
        *"Nanostation M")
                name="nanostation-m"
+               ubnt_xm_board_detect
                ;;
        *"Nanostation M XW")
                name="nanostation-m-xw"
@@ -781,6 +832,7 @@ ar71xx_board_detect() {
                ;;
        *"Rocket M")
                name="rocket-m"
+               ubnt_xm_board_detect
                ;;
        *"Rocket M TI")
                name="rocket-m-ti"
@@ -1088,6 +1140,12 @@ ar71xx_board_detect() {
        *WHR-HP-G300N)
                name="whr-hp-g300n"
                ;;
+       *Z1)
+               name="z1"
+               ;;
+       *ZBT-WE1526)
+               name="zbt-we1526"
+               ;;
        *ZCN-1523H-2)
                name="zcn-1523h-2"
                ;;