From patchwork Tue May 9 09:17:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Yeryomin X-Patchwork-Id: 759978 X-Patchwork-Delegate: openwrt@kresin.me Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wMYgH6PQwz9s7C for ; Tue, 9 May 2017 19:17:47 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="QIo5/Bjh"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="sMWT1DQ7"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:Message-Id:Date:To: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=R9h7cBLi5ezTBltRHyvsg7t3Ci/jF8BezA2r1mTAFJk=; b=QIo5/BjhCk/Z5g 3HxXudeQ2FfTjIhybnbYXxH+ghNGJ8Keze0iHXwzQcUwCa+4JDyElowjPGEcdGDU2jr8st75lY0GW CLq8SoAL2OGIgTrCUBbhGSx9ubRlpr0D9wtny4nSq2rQAiz5I1TxfU6s/cVmhObJFjg8UmpfNBhI7 fEzja25S6j15iDO+ZPLcrEfuCQwruX0ZmyGYgB3UBXHR0Wwn/gvUklwgTHfBYX2/cY5RY0rQHSiRn Nm1/Gkw8ooibYGYCVc8b0V402OIK6JY/8Y3UAqsMG5mAO5lSWzD3faiDws0JkwkirZFxg9m0MlBVr DmnVifrUJ02U9ivvyQ0g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d81H5-0006Vj-Ms; Tue, 09 May 2017 09:17:43 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d81H0-000646-FG for lede-dev@lists.infradead.org; Tue, 09 May 2017 09:17:42 +0000 Received: by mail-wm0-x243.google.com with SMTP id v4so16247368wmb.2 for ; Tue, 09 May 2017 02:17:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=lVUkVkE8jLTmoEUU4LQu12IS+hmY2DME1n4bFTLR89c=; b=sMWT1DQ7dHQxfZLCOQlUR/gb7MdEgUGPAsZAAHeuqFnGv345ZuHypbz5dAlCCmPB9H xw4pG+G4YRvTGXLyWZnW2S8uZnAmj5weSW5vEAwy5LqfOYK2cvJGhdrImTAh4xPapI6W AMIA2JVL/5xq5RMTcf5oWxQii2VXLiSfPkdm0+mJWRNSPcN1Ei1/rPin54qyVfbPqC2j DJRPUf0uj01gzgEyhgaIKF4zBb1fZiZDUDJrcEzoFh7L/QfIv56kLMJRUzIEIkEQTJED XjKpS+aXH+dvkRvwR3cGtlpjKEnVp2Qo/QB6NmojKGKt4/SnWev4ZckzuORM3DkzY7oA 5WXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=lVUkVkE8jLTmoEUU4LQu12IS+hmY2DME1n4bFTLR89c=; b=Xro35sW3mFiM9q0Buc5k4355rAFBk5tCGJKDLOF034jWsRel/hH+Ah7h0ssFgMwBIZ Afg06HNIUdtoAZf6U7sILiWb7Is/s0KWn+Ct27r0R2g/N9ParuYZvEVjajt2cFloSWKp aJDMgjezU9QFpR5Vdh+716fCMK43bh7WLx35AeVeL5czvMj3ezldf4lXgMkYc3kD9zyH rfJgMLrCd1njK9KbSUKAZk9851jqTbegpvCnvYNNs7fWHrXizypOeGGiGeOrffQw6U6+ g0naRoej42EKWlYeR+/AKAVRq0OnyZlgul5JrYvTNmotv6MDrkJpPzVNvMqsugLZJ3ul N03A== X-Gm-Message-State: AN3rC/7ZcAl+Ssiyj0x4+QxYMgNjmFTMclVIMUPDLqt/Eva+6NXKyJqp k4Poh1mLbrhCtp/D X-Received: by 10.25.205.138 with SMTP id d132mr23512390lfg.47.1494321436632; Tue, 09 May 2017 02:17:16 -0700 (PDT) Received: from localhost.localdomain ([213.175.92.61]) by smtp.googlemail.com with ESMTPSA id 129sm1990147ljf.36.2017.05.09.02.17.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 May 2017 02:17:15 -0700 (PDT) From: Roman Yeryomin X-Google-Original-From: Roman Yeryomin To: LEDE Development List Date: Tue, 9 May 2017 12:17:11 +0300 Message-Id: <1494321431-7525-1-git-send-email-roman@advem.lv> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170509_021739_153121_A9C05555 X-CRM114-Status: GOOD ( 12.80 ) X-Spam-Score: -1.7 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:243 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (leroi.lists[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 1.0 FREEMAIL_REPLY From and body contain different freemails Subject: [LEDE-DEV] [PATCH v2 3/3] ipq806x: migrate to generic board detect infrastructure X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Signed-off-by: Roman Yeryomin --- .../linux/ipq806x/base-files/etc/board.d/01_leds | 4 +- .../ipq806x/base-files/etc/board.d/02_network | 4 +- target/linux/ipq806x/base-files/etc/diag.sh | 13 +++- .../etc/hotplug.d/firmware/11-ath10k-caldata | 3 +- .../etc/hotplug.d/ieee80211/10_fix_wifi_mac | 4 +- .../ipq806x/base-files/etc/init.d/linksys_recovery | 3 +- .../linux/ipq806x/base-files/lib/board_detect.sh | 60 ++++++++++++++++ target/linux/ipq806x/base-files/lib/ipq806x.sh | 82 ---------------------- .../lib/preinit/03_preinit_do_ipq806x.sh | 12 ---- .../ipq806x/base-files/lib/upgrade/platform.sh | 8 +-- 10 files changed, 84 insertions(+), 109 deletions(-) create mode 100644 target/linux/ipq806x/base-files/lib/board_detect.sh delete mode 100644 target/linux/ipq806x/base-files/lib/ipq806x.sh delete mode 100644 target/linux/ipq806x/base-files/lib/preinit/03_preinit_do_ipq806x.sh diff --git a/target/linux/ipq806x/base-files/etc/board.d/01_leds b/target/linux/ipq806x/base-files/etc/board.d/01_leds index 1371767..85c94f0 100755 --- a/target/linux/ipq806x/base-files/etc/board.d/01_leds +++ b/target/linux/ipq806x/base-files/etc/board.d/01_leds @@ -4,11 +4,11 @@ # . /lib/functions/uci-defaults.sh -. /lib/ipq806x.sh +. /lib/functions/board.sh board_config_update -board=$(ipq806x_board_name) +board=$(board_name) case "$board" in c2600) diff --git a/target/linux/ipq806x/base-files/etc/board.d/02_network b/target/linux/ipq806x/base-files/etc/board.d/02_network index bd81a1e..fdcc7e7 100755 --- a/target/linux/ipq806x/base-files/etc/board.d/02_network +++ b/target/linux/ipq806x/base-files/etc/board.d/02_network @@ -5,12 +5,12 @@ # . /lib/functions/uci-defaults.sh -. /lib/ipq806x.sh +. /lib/functions/board.sh . /lib/functions/system.sh board_config_update -board=$(ipq806x_board_name) +board=$(board_name) case "$board" in ap148 |\ diff --git a/target/linux/ipq806x/base-files/etc/diag.sh b/target/linux/ipq806x/base-files/etc/diag.sh index 7c9a9d0..0d3c6b0 100755 --- a/target/linux/ipq806x/base-files/etc/diag.sh +++ b/target/linux/ipq806x/base-files/etc/diag.sh @@ -2,7 +2,18 @@ # Copyright (C) 2016 Henryk Heisig hyniu@o2.pl . /lib/functions/leds.sh -. /lib/ipq806x.sh + +ipq806x_get_dt_led() { + local label + local ledpath + local basepath="/sys/firmware/devicetree/base" + local nodepath="$basepath/aliases/led-$1" + + [ -f "$nodepath" ] && ledpath=$(cat "$nodepath") + [ -n "$ledpath" ] && label=$(cat "$basepath$ledpath/label") + + echo "$label" +} boot="$(ipq806x_get_dt_led boot)" failsafe="$(ipq806x_get_dt_led failsafe)" diff --git a/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index 6526212..9d9e21d 100644 --- a/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -38,11 +38,10 @@ ath10kcal_patch_mac() { [ -e /lib/firmware/$FIRMWARE ] && exit 0 -. /lib/ipq806x.sh . /lib/functions.sh . /lib/functions/system.sh -board=$(ipq806x_board_name) +board=$(board_name) case "$FIRMWARE" in diff --git a/target/linux/ipq806x/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ipq806x/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac index 2ea408d..c24a18f 100644 --- a/target/linux/ipq806x/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac +++ b/target/linux/ipq806x/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -6,10 +6,10 @@ PHYNBR=${DEVPATH##*/phy} [ -n $PHYNBR ] || exit 0 -. /lib/ipq806x.sh +. /lib/functions/board.sh . /lib/functions/system.sh -board=$(ipq806x_board_name) +board=$(board_name) case "$board" in c2600) diff --git a/target/linux/ipq806x/base-files/etc/init.d/linksys_recovery b/target/linux/ipq806x/base-files/etc/init.d/linksys_recovery index b9ea004..4d94f1f 100755 --- a/target/linux/ipq806x/base-files/etc/init.d/linksys_recovery +++ b/target/linux/ipq806x/base-files/etc/init.d/linksys_recovery @@ -4,9 +4,8 @@ START=97 boot() { . /lib/functions.sh -. /lib/ipq806x.sh -case $(ipq806x_board_name) in +case $(board_name) in ea8500) # make sure auto_recovery in uboot is always on AUTO_RECOVERY_ENA="`fw_printenv -n auto_recovery`" diff --git a/target/linux/ipq806x/base-files/lib/board_detect.sh b/target/linux/ipq806x/base-files/lib/board_detect.sh new file mode 100644 index 0000000..eb4100e --- /dev/null +++ b/target/linux/ipq806x/base-files/lib/board_detect.sh @@ -0,0 +1,60 @@ +#!/bin/sh +# +# Copyright (c) 2014-2017 The Linux Foundation. All rights reserved. +# Copyright (C) 2011-2017 OpenWrt.org +# + +board_detect() { + local IPQ806X_BOARD_NAME= + local IPQ806X_MODEL= + local machine + local name + + machine=$(cat /proc/device-tree/model) + + case "$machine" in + *"AP148") + name="ap148" + ;; + *"4040") + name="fritz4040" + ;; + *"C2600") + name="c2600" + ;; + *"D7800") + name="d7800" + ;; + *"DB149") + name="db149" + ;; + *"NBG6817") + name="nbg6817" + ;; + *"R7500") + name="r7500" + ;; + *"R7500v2") + name="r7500v2" + ;; + *"Linksys EA8500"*) + name="ea8500" + ;; + *"R7800") + name="r7800" + ;; + *"VR2600v") + name="vr2600v" + ;; + esac + + [ -z "$name" ] && name="unknown" + + [ -z "$IPQ806X_BOARD_NAME" ] && IPQ806X_BOARD_NAME="$name" + [ -z "$IPQ806X_MODEL" ] && IPQ806X_MODEL="$machine" + + [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/" + + echo "$IPQ806X_BOARD_NAME" > /tmp/sysinfo/board_name + echo "$IPQ806X_MODEL" > /tmp/sysinfo/model +} diff --git a/target/linux/ipq806x/base-files/lib/ipq806x.sh b/target/linux/ipq806x/base-files/lib/ipq806x.sh deleted file mode 100644 index 348a3a8..0000000 --- a/target/linux/ipq806x/base-files/lib/ipq806x.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2014 The Linux Foundation. All rights reserved. -# Copyright (C) 2011 OpenWrt.org -# - -IPQ806X_BOARD_NAME= -IPQ806X_MODEL= - -ipq806x_board_detect() { - local machine - local name - - machine=$(cat /proc/device-tree/model) - - case "$machine" in - *"AP148") - name="ap148" - ;; - *"4040") - name="fritz4040" - ;; - *"C2600") - name="c2600" - ;; - *"D7800") - name="d7800" - ;; - *"DB149") - name="db149" - ;; - *"NBG6817") - name="nbg6817" - ;; - *"R7500") - name="r7500" - ;; - *"R7500v2") - name="r7500v2" - ;; - *"Linksys EA8500"*) - name="ea8500" - ;; - *"R7800") - name="r7800" - ;; - *"VR2600v") - name="vr2600v" - ;; - esac - - [ -z "$name" ] && name="unknown" - - [ -z "$IPQ806X_BOARD_NAME" ] && IPQ806X_BOARD_NAME="$name" - [ -z "$IPQ806X_MODEL" ] && IPQ806X_MODEL="$machine" - - [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/" - - echo "$IPQ806X_BOARD_NAME" > /tmp/sysinfo/board_name - echo "$IPQ806X_MODEL" > /tmp/sysinfo/model -} - -ipq806x_board_name() { - local name - - [ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name) - [ -z "$name" ] && name="unknown" - - echo "$name" -} - -ipq806x_get_dt_led() { - local label - local ledpath - local basepath="/sys/firmware/devicetree/base" - local nodepath="$basepath/aliases/led-$1" - - [ -f "$nodepath" ] && ledpath=$(cat "$nodepath") - [ -n "$ledpath" ] && label=$(cat "$basepath$ledpath/label") - - echo "$label" -} diff --git a/target/linux/ipq806x/base-files/lib/preinit/03_preinit_do_ipq806x.sh b/target/linux/ipq806x/base-files/lib/preinit/03_preinit_do_ipq806x.sh deleted file mode 100644 index 785f1eb..0000000 --- a/target/linux/ipq806x/base-files/lib/preinit/03_preinit_do_ipq806x.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2014 The Linux Foundation. All rights reserved. -# - -do_ipq806x() { - . /lib/ipq806x.sh - - ipq806x_board_detect -} - -boot_hook_add preinit_main do_ipq806x diff --git a/target/linux/ipq806x/base-files/lib/upgrade/platform.sh b/target/linux/ipq806x/base-files/lib/upgrade/platform.sh index 8970285..1e4a006 100644 --- a/target/linux/ipq806x/base-files/lib/upgrade/platform.sh +++ b/target/linux/ipq806x/base-files/lib/upgrade/platform.sh @@ -1,4 +1,4 @@ -. /lib/ipq806x.sh +. /lib/functions/board.sh PART_NAME=firmware REQUIRE_IMAGE_METADATA=1 @@ -8,7 +8,7 @@ platform_check_image() { } platform_pre_upgrade() { - local board=$(ipq806x_board_name) + local board=$(board_name) case "$board" in ap148 |\ @@ -26,7 +26,7 @@ platform_pre_upgrade() { } platform_do_upgrade() { - local board=$(ipq806x_board_name) + local board=$(board_name) case "$board" in c2600) @@ -49,7 +49,7 @@ platform_do_upgrade() { } platform_nand_pre_upgrade() { - local board=$(ipq806x_board_name) + local board=$(board_name) case "$board" in nbg6817)