5d31b6741d16f7e9167bba0ff97e83b66709164d
[openwrt/openwrt.git] / target / linux / at91 / base-files / lib / at91.sh
1 #!/bin/sh
2 #
3 # Copyright (C) 2014 OpenWrt.org
4 #
5
6 AT91_BOARD_NAME=
7 AT91_MODEL=
8
9 at91_board_detect() {
10 local machine
11 local name
12
13 machine=$(cat /proc/device-tree/model)
14
15 case "$machine" in
16 *"Atmel at91sam9263ek")
17 name="at91sam9263ek"
18 ;;
19 *"Atmel AT91SAM9G15-EK")
20 name="at91sam9g15ek"
21 ;;
22 *"Atmel at91sam9g20ek")
23 name="at91sam9g20ek"
24 ;;
25 *"Atmel at91sam9g20ek 2 mmc")
26 name="at91sam9g20ek_2mmc"
27 ;;
28 *"Atmel AT91SAM9G25-EK")
29 name="at91sam9g25ek"
30 ;;
31 *"Atmel AT91SAM9G35-EK")
32 name="at91sam9g35ek"
33 ;;
34 *"Atmel AT91SAM9M10G45-EK")
35 name="at91sam9m10g45ek"
36 ;;
37 *"Atmel AT91SAM9X25-EK")
38 name="at91sam9x25ek"
39 ;;
40 *"Atmel AT91SAM9X35-EK")
41 name="at91sam9x35ek"
42 ;;
43 *"SAMA5D3 Xplained")
44 name="sama5d3_xplained"
45 ;;
46 *"Atmel SAMA5D27 SOM1 EK")
47 name="sama5d27_som1_ek"
48 ;;
49 *"SAMA5D2 Xplained")
50 name="sama5d2_xplained"
51 ;;
52 *"SAMA5D4 Xplained")
53 name="sama5d4_xplained"
54 ;;
55 *"CalAmp LMU5000")
56 name="lmu5000"
57 ;;
58 *"Calao TNY A9260")
59 name="tny_a9260"
60 ;;
61 *"Calao TNY A9263")
62 name="tny_a9263"
63 ;;
64 *"Calao TNY A9G20")
65 name="tny_a9g20"
66 ;;
67 *"Calao USB A9260")
68 name="usb_a9260"
69 ;;
70 *"Calao USB A9263")
71 name="usb_a9263"
72 ;;
73 *"Calao USB A9G20")
74 name="usb_a9g20"
75 ;;
76 *"Ethernut 5")
77 name="ethernut5"
78 ;;
79 esac
80
81 [ -z "$name" ] && name="unknown"
82
83 [ -z "$AT91_BOARD_NAME" ] && AT91_BOARD_NAME="$name"
84 [ -z "$AT91_MODEL" ] && AT91_MODEL="$machine"
85
86 [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
87
88 echo "$AT91_BOARD_NAME" > /tmp/sysinfo/board_name
89 echo "$AT91_MODEL" > /tmp/sysinfo/model
90 }