summaryrefslogtreecommitdiff
path: root/target/linux/archs38/base-files/lib/arc.sh
blob: 99d0077f6742bcb056bbcbb9aa448f304f7b65d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
#
# Copyright (C) 2016 OpenWrt.org
#

# defaults
ARC_BOARD_NAME="generic"
ARC_BOARD_MODEL="Generic ARC board"

arc_board_detect() {
	local board
	local model
	local compatible

	[ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"

	model="$( cat /proc/device-tree/model )"
	compatible="$( cat /proc/device-tree/compatible )"

	case "$compatible" in
	"snps,axs103""snps,arc-sdp")
		board="arc-sdp";
		;;
	"snps,nsim_hs")
		board="arc-nsim";
		;;
	esac

	if [ "$board" != "" ]; then
		ARC_BOARD_NAME="$board"
	fi

	if [ "$model" != "" ]; then
		ARC_BOARD_MODEL="$model"
	fi

	echo "$ARC_BOARD_NAME" > /tmp/sysinfo/board_name
	echo "$ARC_BOARD_MODEL" > /tmp/sysinfo/model
	echo "Detected $ARC_BOARD_NAME // $ARC_BOARD_MODEL"
}

arc_board_name() {
	local name

	[ -f /tmp/sysinfo/board_name ] && name="$(cat /tmp/sysinfo/board_name)"
	[ -z "$name" ] && name="unknown"

	echo "$name"
}