aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ath79/base-files/lib
diff options
context:
space:
mode:
authorWeijie Gao <hackpascal@gmail.com>2018-06-13 21:14:49 +0800
committerJohn Crispin <john@phrozen.org>2018-06-18 18:21:16 +0200
commit97c5cbc496e9cf8139994cd3ea987f4e9c70adbe (patch)
tree8d04f701b5020cc5c10d17826aa522ad08279281 /target/linux/ath79/base-files/lib
parent8f804f42d52e49191429ad1d716e7adb3cd10ceb (diff)
downloadupstream-97c5cbc496e9cf8139994cd3ea987f4e9c70adbe.tar.gz
upstream-97c5cbc496e9cf8139994cd3ea987f4e9c70adbe.tar.bz2
upstream-97c5cbc496e9cf8139994cd3ea987f4e9c70adbe.zip
ath79: add support for Phicomm K2T
This patch adds dts for qca956x and also support for Phicomm K2T The qca965x.dtsi adds nearly all the necessary components. Both ath9k AHB and PCIe worked well. The Phicomm K2T uses MTD partition 'config' to store the mac addresses in JSON format. To extract these fields correctly, a script is introduced: /lib/functions/k2t.sh This script provides a helper function to extract mac addresses, and is used in three places. Hardware spec of Phicomm K2T: CPU: QCA9563 DRAM: 64MB DDR2 Flash: 16MB SPI-NOR Switch: QCA8337 WiFi 5.8GHz: QCA9886 Flash instruction: Apply sysupgrade.bin via serial console: tftp 0x80000000 sysupgrade.bin && erase 0x9f090000 +$filesize && cp.b $fileaddr 0x9f090000 $filesize Signed-off-by: Weijie Gao <hackpascal@gmail.com>
Diffstat (limited to 'target/linux/ath79/base-files/lib')
-rwxr-xr-xtarget/linux/ath79/base-files/lib/functions/k2t.sh55
1 files changed, 55 insertions, 0 deletions
diff --git a/target/linux/ath79/base-files/lib/functions/k2t.sh b/target/linux/ath79/base-files/lib/functions/k2t.sh
new file mode 100755
index 0000000000..1158df818b
--- /dev/null
+++ b/target/linux/ath79/base-files/lib/functions/k2t.sh
@@ -0,0 +1,55 @@
+#!/bin/sh
+#
+# Copyright (C) 2018 Weijie Gao <hackpascal@gmail.com>
+#
+# Helper function to extract mac addresses from mtd part for Phicomm K2T
+#
+
+. /lib/functions.sh
+. /lib/functions/system.sh
+. /usr/share/libubox/jshn.sh
+
+k2t_config_load() {
+ local mtd_blk=$(find_mtd_part config)
+
+ if [ -z "$mtd_blk" ]; then
+ echo "k2t_config_load: no mtd part named config" >&2
+ exit 1
+ fi
+
+ local json_size=$(dd if=$mtd_blk bs=1 count=8 2>/dev/null)
+
+ json_size="0x$json_size"
+ json_size=$((json_size))
+
+ if [ "$?" -ne 0 ]; then
+ echo "k2t_config_load: invalid json data size" >&2
+ exit 2
+ fi
+
+ if [ "$json_size" -eq 0 ]; then
+ echo "k2t_config_load: empty json data" >&2
+ exit 3
+ fi
+
+ local json_data=$(dd if=$mtd_blk bs=1 skip=8 count=$json_size 2>/dev/null)
+
+ json_load "$json_data"
+}
+
+k2t_get_mac() {
+ local old_ns
+
+ json_set_namespace "k2t" old_ns
+
+ if k2t_config_load; then
+ json_select "this_dev_info"
+ json_get_var val "$1"
+ json_select ..
+ fi
+
+ json_set_namespace old_ns
+
+ echo $val
+}
+