apm821xx: add support for the apm821xx device target
[openwrt/openwrt.git] / target / linux / apm821xx / base-files / lib / apm821xx.sh
1 #!/bin/sh
2
3 APM821XX_BOARD_NAME=
4 APM821XX_MODEL=
5
6 apm821xx_board_detect() {
7 local model
8 local name
9
10 model=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /model/ {print $2}' /proc/cpuinfo)
11
12 case "$model" in
13 *)
14 name="unknown"
15 ;;
16 esac
17
18 [ -z "$name" ] && name="unknown"
19
20 [ -z "$APM821XX_BOARD_NAME" ] && APM821XX_BOARD_NAME="$name"
21 [ -z "$APM821XX_MODEL" ] && APM821XX_MODEL="$model"
22
23 [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
24
25 echo "$APM821XX_BOARD_NAME" > /tmp/sysinfo/board_name
26 echo "$APM821XX_MODEL" > /tmp/sysinfo/model
27 }
28
29 apm821xx_board_name() {
30 local name
31
32 [ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
33 [ -z "$name" ] && name="unknown"
34
35 echo "$name"
36 }