From patchwork Wed Feb 27 22:18:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Schmutzler X-Patchwork-Id: 1049164 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="W5EproTN"; 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 448qpC5G6sz9sBF for ; Thu, 28 Feb 2019 09:18:43 +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=TVVIjevWx5i5cw+0vzuZwwDkvvwpZoaCRgY+hocFPUk=; b=W5EproTNOyg4J7lGRpRPjioFDl XKVBCmncZ7ZLLfm8EizJ5d6k2gVCpFCoodik19YB208h4wVoBGodSdfwH5cqHUG8CKIBSsSgSDPyN gfdP5RT8hquOYz1b9rU4V3ZH0BkMgbTQzNeL2aAkWlekwBNMizP41h4JbTwmsuYB601hF8zHolZNR aCUfzaH3ts8/CMvAdAtuX75MgYWUWN15j8kzLbhzDEicTgSkEgkyohMxWS0zhJzKasFuxQr0JwIod Ki4ZwRZekX6knkbQHQpZM5P4JuGCoFsyHtF4yfktTSa3J0aKYcxbvQJfwV65NJAk/2cr5FXPu1Rc1 iMH1WTfg==; 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 1gz7X1-0003xv-3F; Wed, 27 Feb 2019 22:18:27 +0000 Received: from mout.kundenserver.de ([212.227.17.24]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gz7Wr-0003o1-82 for openwrt-devel@lists.openwrt.org; Wed, 27 Feb 2019 22:18:19 +0000 Received: from localhost.localdomain ([188.194.105.77]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MvrVJ-1hF01C37iR-00sydn for ; Wed, 27 Feb 2019 23:18:13 +0100 From: Adrian Schmutzler To: openwrt-devel@lists.openwrt.org Date: Wed, 27 Feb 2019 23:18:08 +0100 Message-Id: <20190227221809.1697-6-freifunk@adrianschmutzler.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190227221809.1697-1-freifunk@adrianschmutzler.de> References: <20190227221809.1697-1-freifunk@adrianschmutzler.de> X-Provags-ID: V03:K1:gahrzM3qPt8h0qlUEMvqLcqXCBT5w2UzkYykrDMSXyB6p9NZ6YG zZtUG0r+QM5Vp3DS0FiS+9UhS86ed+15WPGHjQjJqv3F/24FiGVXOPr03D1KVCsauY4xgR+ g1EMRKrAf01vY68v9nY9WsPEdRasiaONWb51yIimL1MS0jZS7UkgWaPtf9XSZhilCcPnZ3b 3RobUaZsdxb3K0rb74JrA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:fqe1r2WDD4M=:yKUbVL7Ff8mWJ+PgT15hnT JQaIWqj9RKNR1Ryu2gp7sawCxwHjmCoST2Isfp5Rp+HuZ5jeJ0lnFIUOaG8OsFhm3y4tuEaI/ ijR9Pn1sROHmvtC4kAzgfa/LAOGQ15O7v9yyeOphxo41cjfzUT7gSDVWXopyb4utDdUdJZLks 5Xkb4VFaRUW7Y2tb8q0TIPDYoDFZwxsvD6VEkkU+vnLdBjdOxxgWJsH0eR5/95liri8bG1ItR 705r1SGxPnIWTFT8B+NR1DDgqkRSgSEacMOH7dlOiLFH5Z8ojKdiRH5CGbZUzMLqWXB8mmItP PORGV8sffFJuMuTPYVSrNKq/AlEuFkUtFUb3ZDoR3qOt2lZin9lgC4bZsbLYFnuKQsxxEvlyU 9tVu2t8IHZVTzPOiNA/KBVoonrbDJjQyKxbqVvjQI9p1GiZyqTEhf1yryzsXCGaBR5ISpTeQ0 sBIPPwvl1d1iBtJV2hGQ7PJ9zkwKHzZtXXC3ZqrrJQuC+4BN1ASS7cihh5rymTzEzXVo0oZSr vauNbwTEVciD7H13eevRXVr9ryGurXHgImxMWoKbLNIpBTRZIGVcEEbGIng3myKjhF8ywxSUE 3rzYFZXwI6SXUsvWlkp1QSYtTY3ALC8pUXf9kGqDs7G2EPxPg6uHSMAR5XSTF02I3Fo5lXx6V O06y78QNemB5B4xCoaH6sfbFSVlkQSGGdM+yJ20NHngcmPiodd7WDWKPgWyOAlmnpXH9KVyYg hxaSJyulkxFCKBMa+4/H/Sj8phg9NOIp4rzDSKRRn9iLTh/vpGLOyWZx6o0= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190227_141817_587745_2FD61570 X-CRM114-Status: GOOD ( 11.88 ) 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 http://www.dnswl.org/, no trust [212.227.17.24 listed in list.dnswl.org] Subject: [OpenWrt-Devel] [PATCH v3 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 --- 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 718224f1e0..c13b3e9ecd 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,37 +85,37 @@ 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") ;; 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) ;; compex,wpj428 |\ engenius,eap1300 |\ openmesh,a42 |\ openmesh,a62) - ath10kcal_extract "0:ART" 4096 12064 + mtd_eeprom_extract "0:ART" 4096 12064 ;; 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 @@ -165,37 +127,37 @@ 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") ;; 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) ;; compex,wpj428 |\ engenius,eap1300 |\ openmesh,a42 |\ openmesh,a62) - ath10kcal_extract "0:ART" 20480 12064 + mtd_eeprom_extract "0:ART" 20480 12064 ;; 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