From patchwork Fri Mar 1 14:40:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Schmutzler X-Patchwork-Id: 1050231 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adrianschmutzler.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="IJX+aDur"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::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 449sYT1TQWz9s4V for ; Sat, 2 Mar 2019 01:41:17 +1100 (AEDT) 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:References: In-Reply-To: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:List-Owner; bh=REwGdF6sE5fPqKGJxTiaShx/klesoLG9lmepLllm1c0=; b=IJX+aDurYFo8GPODGbL2AfFG8V ibig+49gQ+ushanXFPrxLWEz2IHtIk0CSntMPUw1nZ7j8oN5sAUsbs7WMk//JAL4IQt6fOb9tpOOt JXTTC1viKc8begu69iiuSpC6vy85SN1uE+WoiHCFknTx8I/e2HzRFBPEtjGNP/jXpnmM5uWgzldFo /3b+Xyjpjeg4P0ijpEoP1E2+htNVZGe4kyyVGaEZbHkRTh0yGNbKqlX7VN2YVr+OWFUXBtY8Rf5YF 0FW+3rfQ5q9gogdAzaTyj4rV1CiaQGnImM+O8AHI819OZtQi+vae2Ea3epymaXtaT+z/vlxqdy0pB sjVnG0Ww==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzjLT-0006XQ-FP; Fri, 01 Mar 2019 14:41:03 +0000 Received: from mout.kundenserver.de ([212.227.126.134]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzjKy-0005pW-BO for openwrt-devel@lists.openwrt.org; Fri, 01 Mar 2019 14:40:35 +0000 Received: from localhost.localdomain ([188.194.105.77]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MoOIi-1hJj9A146y-00okWO for ; Fri, 01 Mar 2019 15:40:28 +0100 From: Adrian Schmutzler To: openwrt-devel@lists.openwrt.org Date: Fri, 1 Mar 2019 15:40:21 +0100 Message-Id: <20190301144022.1984-6-freifunk@adrianschmutzler.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190301144022.1984-1-freifunk@adrianschmutzler.de> References: <20190301144022.1984-1-freifunk@adrianschmutzler.de> X-Provags-ID: V03:K1:pmArQH0lgFzl/cIV+rktQ8zW9DK9Z6PCBgXsCmjdvYluZ8NBV6O tKuJ/vd291i+htT71o2DDU4TxyZiWIPFAilw9Jza8+ATFVoTpDrVF9YfsBBfIegx465d7fr qoD/8PNK4TWge6KBPdejeNJ3IsFFs1IATXeOcgkZgligXAwaSwPqkt27w+ds3KgiQGo4MSB BDpXaoONrXbm5Mz0cG/aQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:oAi0mMRMVQc=:IaKUYna9ZAzD6aZY3YCOL6 CnOoCt9XoRO6xtoLgXqU3lXlcdqbQfI8EKdvy3S3BfjtuY0OCFpvF9ItVFH/L8uNEkBzNQd9a Xjj4+rygelOJ6myodrUpWn/wGQmYlvNPofrwbCbZXOeFkHVCi+pnZok81h3QcZ5Qkq7+kmhhv CZuTgmkTlmi+gTtyBdD5/zq0q+XO44VbicohFJz/33QYZy0W7D6ZRHQ8RIpprbXzDzjY6WmDz Y23pxpnky8bpncEHJTmjbNB/w/MFAsUWOCaCxP7tSTTX+3JF7J2nD7hyLSqg+YGp7Cyc35Vz+ AND6oh+CD2ovle1QgOEmCtbPdcrR08TLoBRd3m4/Go68BopD1tnXhU/+GHgeAaK24T5Hc1jPb QSy6BAOug9YQdz47jxuL2TqvPlKrtFq1pYI83BJVL3VWv+GmGVunOoFFqy0JJaBhBtjrKCiim 1MQ1JE4JdwKZdhRzrRsfpqNP7N37PWser/zDqQ3wwik51GuZyX1pdCW1qiRjeESe5r/MZVuqA tgvANW+VDBkQya8q63XwAuEZXIG5eVWwNV/CeIXEOv+dCKu3UdEkwUE/VpAkga5UD0iM/AagN PGSepDQUqr0g7cR2DX0bNBwkT9BL/f1j0H1fdhATeKhneKRDS8oSnvI6qwtmxs75CVf5/K6qU WfxUKlOAJWu4dQ14MR1423Xdb4ZXuRpjA88VR73nSUmvJImALbUwYKQJwN7harZu1v6IrmvP1 OhCao3/FvPg6m8DSUv3LPgOUgAuavSF1QFdUGGzpssDp0LChhjSpvsk6M10= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190301_064032_689812_75D072C5 X-CRM114-Status: GOOD ( 10.40 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [212.227.126.134 listed in list.dnswl.org] Subject: [OpenWrt-Devel] [PATCH v4 5/6] ipq40xx: Make use of common eeprom.sh library for caldata X-BeenThere: openwrt-devel@lists.openwrt.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: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org This merges the ath10k-caldata extraction into the common eeprom.sh. Signed-off-by: Adrian Schmutzler --- New in v3: Moved over from alternate patchset Changed in v4: - Rebased --- package/base-files/files/lib/functions/eeprom.sh | 5 +- .../etc/hotplug.d/firmware/11-ath10k-caldata | 82 ++++++---------------- 2 files changed, 26 insertions(+), 61 deletions(-) diff --git a/package/base-files/files/lib/functions/eeprom.sh b/package/base-files/files/lib/functions/eeprom.sh index 80df3bb359..48c7fd362d 100644 --- a/package/base-files/files/lib/functions/eeprom.sh +++ b/package/base-files/files/lib/functions/eeprom.sh @@ -67,9 +67,12 @@ ubi_eeprom_extract() { local part=$1 local offset=$2 local count=$3 - local ubidev=$(nand_find_ubi $CI_UBIPART) + local ubidev local ubi + . /lib/upgrade/nand.sh + + ubidev=$(nand_find_ubi $CI_UBIPART) ubi=$(nand_find_volume $ubidev $part) [ -n "$ubi" ] || \ eeprom_die "no UBI volume found for $part" diff --git a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index 1264d2ef36..75e8f1a237 100644 --- a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -1,5 +1,7 @@ #!/bin/sh +. /lib/functions/eeprom.sh + # xor multiple hex values of the same length xor() { local val @@ -16,43 +18,6 @@ xor() { printf "%0${retlen}x" "$ret" } -ath10kcal_die() { - echo "ath10cal: " "$*" - exit 1 -} - -ath10kcal_extract() { - local part=$1 - local offset=$2 - local count=$3 - local mtd - - mtd=$(find_mtd_chardev $part) - [ -n "$mtd" ] || \ - ath10kcal_die "no mtd device found for partition $part" - - dd if=$mtd of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \ - ath10kcal_die "failed to extract calibration data from $mtd" -} - -ath10kcal_ubi_extract() { - local part=$1 - local offset=$2 - local count=$3 - local ubidev - local ubi - - . /lib/upgrade/nand.sh - - ubidev=$(nand_find_ubi $CI_UBIPART) - ubi=$(nand_find_volume $ubidev $part) - [ -n "$ubi" ] || \ - ath10kcal_die "no UBI volume found for $part" - - dd if=/dev/$ubi of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \ - ath10kcal_die "failed to extract from $ubi" -} - ath10kcal_patch_mac_crc() { local mac=$1 local mac_offset=6 @@ -88,9 +53,6 @@ ath10kcal_is_caldata_valid() { [ -e /lib/firmware/$FIRMWARE ] && exit 0 -. /lib/functions.sh -. /lib/functions/system.sh - board=$(board_name) @@ -98,8 +60,8 @@ case "$FIRMWARE" in "ath10k/cal-pci-0000:01:00.0.bin") case "$board" in meraki,mr33) - ath10kcal_ubi_extract "ART" 36864 2116 - ath10kcal_is_caldata_valid "4408" || ath10kcal_extract "ART" 36864 2116 + ubi_eeprom_extract "ART" 36864 2116 + ath10kcal_is_caldata_valid "4408" || mtd_eeprom_extract "ART" 36864 2116 ath10kcal_patch_mac_crc $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 102) +1) ;; esac @@ -107,12 +69,12 @@ case "$FIRMWARE" in "ath10k/pre-cal-pci-0000:01:00.0.bin") case "$board" in asus,map-ac2200) - ath10kcal_ubi_extract "Factory" 36864 12064 + ubi_eeprom_extract "Factory" 36864 12064 ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \ /lib/firmware/ath10k/QCA9888/hw2.0/board.bin ;; openmesh,a62) - ath10kcal_extract "0:ART" 36864 12064 + mtd_eeprom_extract "0:ART" 36864 12064 ;; esac ;; @@ -123,14 +85,14 @@ case "$FIRMWARE" in glinet,gl-b1300 |\ linksys,ea6350v3 |\ qcom,ap-dk01.1-c1) - ath10kcal_extract "ART" 4096 12064 + mtd_eeprom_extract "ART" 4096 12064 ;; asus,map-ac2200) - ath10kcal_ubi_extract "Factory" 4096 12064 + ubi_eeprom_extract "Factory" 4096 12064 ;; asus,rt-ac58u) CI_UBIPART=UBI_DEV - ath10kcal_ubi_extract "Factory" 4096 12064 + ubi_eeprom_extract "Factory" 4096 12064 ;; avm,fritzbox-4040) /usr/bin/fritz_cal_extract -i 1 -s 0x400 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader_config") @@ -145,21 +107,21 @@ case "$FIRMWARE" in openmesh,a62 |\ qxwlan,e2600ac-c1 |\ qxwlan,e2600ac-c2) - ath10kcal_extract "0:ART" 4096 12064 + mtd_eeprom_extract "0:ART" 4096 12064 ;; meraki,mr33) - ath10kcal_ubi_extract "ART" 4096 12064 - ath10kcal_is_caldata_valid "202f" || ath10kcal_extract "ART" 4096 12064 + ubi_eeprom_extract "ART" 4096 12064 + ath10kcal_is_caldata_valid "202f" || mtd_eeprom_extract "ART" 4096 12064 ath10kcal_patch_mac_crc $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 102) +2) ;; netgear,ex6100v2 |\ netgear,ex6150v2) - ath10kcal_extract "ART" 4096 12064 + mtd_eeprom_extract "ART" 4096 12064 ath10kcal_patch_mac_crc $(mtd_get_mac_binary dnidata 0) ;; zyxel,nbg6617 |\ zyxel,wre6606) - ath10kcal_extract "ART" 4096 12064 + mtd_eeprom_extract "ART" 4096 12064 ath10kcal_patch_mac_crc $(macaddr_add $(cat /sys/class/net/eth0/address) -2) ;; esac @@ -171,14 +133,14 @@ case "$FIRMWARE" in glinet,gl-b1300 |\ linksys,ea6350v3 |\ qcom,ap-dk01.1-c1) - ath10kcal_extract "ART" 20480 12064 + mtd_eeprom_extract "ART" 20480 12064 ;; asus,map-ac2200) - ath10kcal_ubi_extract "Factory" 20480 12064 + ubi_eeprom_extract "Factory" 20480 12064 ;; asus,rt-ac58u) CI_UBIPART=UBI_DEV - ath10kcal_ubi_extract "Factory" 20480 12064 + ubi_eeprom_extract "Factory" 20480 12064 ;; avm,fritzbox-4040) /usr/bin/fritz_cal_extract -i 1 -s 0x400 -e 0x208 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader_config") @@ -193,21 +155,21 @@ case "$FIRMWARE" in openmesh,a62 |\ qxwlan,e2600ac-c1 |\ qxwlan,e2600ac-c2) - ath10kcal_extract "0:ART" 20480 12064 + mtd_eeprom_extract "0:ART" 20480 12064 ;; meraki,mr33) - ath10kcal_ubi_extract "ART" 20480 12064 - ath10kcal_is_caldata_valid "202f" || ath10kcal_extract "ART" 20480 12064 + ubi_eeprom_extract "ART" 20480 12064 + ath10kcal_is_caldata_valid "202f" || mtd_eeprom_extract "ART" 20480 12064 ath10kcal_patch_mac_crc $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 102) +3) ;; netgear,ex6100v2 |\ netgear,ex6150v2) - ath10kcal_extract "ART" 20480 12064 + mtd_eeprom_extract "ART" 20480 12064 ath10kcal_patch_mac_crc $(mtd_get_mac_binary dnidata 12) ;; zyxel,nbg6617 |\ zyxel,wre6606) - ath10kcal_extract "ART" 20480 12064 + mtd_eeprom_extract "ART" 20480 12064 ath10kcal_patch_mac_crc $(macaddr_add $(cat /sys/class/net/eth0/address) -1) ;; esac