diff options
author | Florian Fainelli <florian@openwrt.org> | 2015-07-04 01:25:15 +0000 |
---|---|---|
committer | Florian Fainelli <florian@openwrt.org> | 2015-07-04 01:25:15 +0000 |
commit | 6c289f2344a99877dc922b1868c0b450a8a3a53d (patch) | |
tree | 0cf641a2140373a5da1820c0e0284fe0d79e63b4 /target | |
parent | 455509fe28a396038681dd373a9705705aca3adc (diff) | |
download | master-187ad058-6c289f2344a99877dc922b1868c0b450a8a3a53d.tar.gz master-187ad058-6c289f2344a99877dc922b1868c0b450a8a3a53d.tar.bz2 master-187ad058-6c289f2344a99877dc922b1868c0b450a8a3a53d.zip |
at91: add Device Tree based board detection
Set up eth0 as LAN interface by default.
Signed-off-by: Florian Fainelli <florian@openwrt.org>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@46174 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target')
-rw-r--r-- | target/linux/at91/base-files.mk | 5 | ||||
-rwxr-xr-x | target/linux/at91/base-files/etc/uci-defaults/02_network | 29 | ||||
-rwxr-xr-x | target/linux/at91/base-files/lib/at91.sh | 90 | ||||
-rw-r--r-- | target/linux/at91/base-files/lib/preinit/03_preinit_do_at91.sh | 6 |
4 files changed, 127 insertions, 3 deletions
diff --git a/target/linux/at91/base-files.mk b/target/linux/at91/base-files.mk new file mode 100644 index 0000000000..d6682bd388 --- /dev/null +++ b/target/linux/at91/base-files.mk @@ -0,0 +1,5 @@ +define Package/base-files/install-target + rm -f $(1)/etc/config/network +endef + + diff --git a/target/linux/at91/base-files/etc/uci-defaults/02_network b/target/linux/at91/base-files/etc/uci-defaults/02_network new file mode 100755 index 0000000000..5df138c72c --- /dev/null +++ b/target/linux/at91/base-files/etc/uci-defaults/02_network @@ -0,0 +1,29 @@ +#!/bin/sh +# +# Copyright (C) 2014 OpenWrt.org +# + +[ -e /etc/config/network ] && exit 0 + +touch /etc/config/network + +. /lib/functions/uci-defaults.sh +. /lib/at91.sh + +ucidef_set_interface_loopback + +case "$(at91_board_name)" in + +sama5d3_xplained) + ucidef_set_interfaces_lan_wan "eth0" "eth1" + ;; + +*) + ucidef_set_interface_lan "eth0" + ;; + +esac + +uci commit network + +exit 0 diff --git a/target/linux/at91/base-files/lib/at91.sh b/target/linux/at91/base-files/lib/at91.sh new file mode 100755 index 0000000000..e395646cbc --- /dev/null +++ b/target/linux/at91/base-files/lib/at91.sh @@ -0,0 +1,90 @@ +#!/bin/sh +# +# Copyright (C) 2014 OpenWrt.org +# + +AT91_BOARD_NAME= +AT91_MODEL= + +at91_board_detect() { + local machine + local name + + machine=$(cat /proc/device-tree/model) + + case "$machine" in + *"Atmel at91sam9263ek") + name="at91sam9263ek" + ;; + *"Atmel AT91SAM9G15-EK") + name="at91sam9g15ek" + ;; + *"Atmel at91sam9g20ek") + name="at91sam9g20ek" + ;; + *"Atmel at91sam9g20ek 2 mmc") + name="at91sam9g20ek_2mmc" + ;; + *"Atmel AT91SAM9G25-EK") + name="at91sam9g25ek" + ;; + *"Atmel AT91SAM9G35-EK") + name="at91sam9g35ek" + ;; + *"Atmel AT91SAM9M10G45-EK") + name="at91sam9m10g45ek" + ;; + *"Atmel AT91SAM9X25-EK") + name="at91sam9x25ek" + ;; + *"Atmel AT91SAM9X35-EK") + name="at91sam9x35ek" + ;; + *"SAMA5D3 Xplained") + name="sama5d3_xplained" + ;; + *"CalAmp LMU5000") + name="lmu5000" + ;; + *"Calao TNY A9260") + name="tny_a9260" + ;; + *"Calao TNY A9263") + name="tny_a9263" + ;; + *"Calao TNY A9G20") + name="tny_a9g20" + ;; + *"Calao USB A9260") + name="usb_a9260" + ;; + *"Calao USB A9263") + name="usb_a9263" + ;; + *"Calao USB A9G20") + name="usb_a9g20" + ;; + *"Ethernut 5") + name="ethernut5" + ;; + esac + + [ -z "$name" ] && name="unknown" + + [ -z "$AT91_BOARD_NAME" ] && AT91_BOARD_NAME="$name" + [ -z "$AT91_MODEL" ] && AT91_MODEL="$machine" + + [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/" + + echo "$AT91_BOARD_NAME" > /tmp/sysinfo/board_name + echo "$AT91_MODEL" > /tmp/sysinfo/model +} + +at91_board_name() { + local name + + [ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name) + [ -n "$name" ] || name="unknown" + + echo "$name" +} diff --git a/target/linux/at91/base-files/lib/preinit/03_preinit_do_at91.sh b/target/linux/at91/base-files/lib/preinit/03_preinit_do_at91.sh index 03706ffe1a..5c981016a4 100644 --- a/target/linux/at91/base-files/lib/preinit/03_preinit_do_at91.sh +++ b/target/linux/at91/base-files/lib/preinit/03_preinit_do_at91.sh @@ -1,9 +1,9 @@ #!/bin/sh do_at91() { - [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/" - echo $(strings /proc/device-tree/compatible | head -1) > /tmp/sysinfo/board_name - echo $(cat /proc/device-tree/model) > /tmp/sysinfo/model + . /lib/at91.sh + + at91_board_detect } boot_hook_add preinit_main do_at91 |