From patchwork Thu Jan 20 13:54:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Denis K X-Patchwork-Id: 1582147 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=qfJPEUeU; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=Alcx8xsw; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) 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=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JfkcB3MhYz9s9c for ; Fri, 21 Jan 2022 00:58:01 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yT9HyQ4i6vAqQHdtZ8aJiyo13mYkRijoFu1x+4wR7NM=; b=qfJPEUeUrMsA4S dBTk7ziYFgCRv2FDEtSo/BQOLNV4GnDQoft2uVf2ULY7Jj5YFmE8M5vQrC3BNkZVTxrPFkXRyMKbc JjOV+7UO5n/ZguBqQGQmymuaneDry0kpZ3G/oDfoSfg8pbjhIXZurQnosuSGPeaWUatvofX9CsP6i FtvJlJ8sFeWJ+hynlLmTOzgAmwjVRnqV7CxW/yPVrESpfenesJ6olFPgUmTrK1gHxNG6zorUOnkQW 54rs2fSQoLQkwOlYq71MOAQNYzHAcZqjuoJEawGJjk8YUfh/QHhbcrXzEEFXhzTQITV3Hzt8mhIg3 Qv/a0PVevXpV7NpnifVg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nAXuH-00BnYh-BO; Thu, 20 Jan 2022 13:55:17 +0000 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nAXuD-00BnXG-OU for openwrt-devel@lists.openwrt.org; Thu, 20 Jan 2022 13:55:15 +0000 Received: by mail-lf1-x131.google.com with SMTP id s30so21925658lfo.7 for ; Thu, 20 Jan 2022 05:55:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RE6dSF1e9JoiBenDazmdC/0zlczbrgQQBlNXpfYlJ9Y=; b=Alcx8xsw6PeKIomcK2SCQKU/Rb9ZUmq593/DozRg4wLZH0AQD0jFTGNVm7p7303Sno OgvSNNwlDHY63Y1oG2Y47uPktcGbpV1DP5NgltNQR32xvXV0HC2ioUp9jIZwBLfwdjkB RcTKYzK/Hv80GhHH+uXkEQhXGujrxdybYsTYJRwUJh5wm+acepy4t7Vlk7UtUL+8Xi62 lccH3ztfaTAxv7QLC86Z6mzweyMZpBYhzCKOyk+848/0PUUxLMoZqNlyou4pkHChWRTb w/TWEX1obA6MYA/xOMVWybY5YNEi6tIi+BpkS9IuGo8uJ+MQCFoNEjNZl1wOYq23PkDh /eGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RE6dSF1e9JoiBenDazmdC/0zlczbrgQQBlNXpfYlJ9Y=; b=QFHWjASRNH0NXKDGtXcKiH6qovRrTxTELmbrv1GQzBhFB2xyGjGPGYGlONXH/djRwg OLrRGAjNX5QQvN/wc6xnRJBXCN95XwfKr0V++U0SMxigd48uLtKFd3YokWtixCKR4HMe 9HF8IhD3oA7ZlR4SV9zH068kGH0ezKlRmq/r4ALQjuajG6pb/iBWjMchZImLkhyj3PDQ x4XTMx0wkS5aNmENHnKDf1ljJ4ykKBkgqQiujdjwMUXXcfssa+b5FPsrszQ9co+izZkf qfw5eqr4As37T3L/C/XkZlIDzvkjd3b6ZMm1XsEijb5KOVZzyj0Hoh2ni9JUYtKf03HQ ax3Q== X-Gm-Message-State: AOAM533HaMHSi8RkldZK/rB4Zd5+WOiArt98Gj1eRaeFHe4HL3S3Cufj 1RZm20q7peIERGCy8NeL1Pyi6mTk9h9n/Q== X-Google-Smtp-Source: ABdhPJz7wcOHzVi8JHXkrpTyHFWp7IJxJ0oBPI5bi9EaMXciq225lHO9wJwOR2V3iq9+B4wMGbY/yw== X-Received: by 2002:a05:6512:15aa:: with SMTP id bp42mr25517328lfb.217.1642686910573; Thu, 20 Jan 2022 05:55:10 -0800 (PST) Received: from kalashnikov.user.kdf.lan ([89.18.140.18]) by smtp.gmail.com with ESMTPSA id o24sm348863lfo.146.2022.01.20.05.55.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jan 2022 05:55:09 -0800 (PST) From: Denis Kalashnikov X-Google-Original-From: Denis Kalashnikov To: OpenWrt Development List , Koen Vandeputte , =?utf-8?q?Thomas_H=C3=BChn?= Cc: Denis Kalashnikov , Sergey Ryazanov Subject: [RFC] ath79: MikroTik RB912UAG-2HPnD: add initial value to SSR Date: Thu, 20 Jan 2022 16:54:20 +0300 Message-Id: <20220120135420.20504-1-d.kalashnikov@kodofon.vrn.ru> X-Mailer: git-send-email 2.31.1 In-Reply-To: <83acb8d4-38d4-2383-f10e-537da151d91c@citymesh.com> References: <83acb8d4-38d4-2383-f10e-537da151d91c@citymesh.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220120_055513_835496_FF44514B X-CRM114-Status: GOOD ( 19.77 ) X-Spam-Score: 0.1 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Denis Kalashnikov ar71xx mach-rb91x.c and others set SSR init value through platform data (this ability is added to upstream drivers/gpio/gpio-74x164.c by 451-gpio-74x164-improve-platform-device-support.patch). When we [...] Content analysis details: (0.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:131 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [denis281089[at]gmail.com] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [denis281089[at]gmail.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Denis Kalashnikov ar71xx mach-rb91x.c and others set SSR init value through platform data (this ability is added to upstream drivers/gpio/gpio-74x164.c by 451-gpio-74x164-improve-platform-device-support.patch). When we ported RB912UAG-2HPnD to ath79, we used DTS gpio-exports instead. But this broke some mPCIe cards. To fix this we turn back to gpio-74x164 the ability to get an init value from DTS. Why is using DTS gpio-hog option not good in this case? Since then gpio-export of the hogged line is not working. But we need it, since with pcie_power and usb_power we can reset USB devices, e.g cell modems. Also move SSR beeper pin value from gpio-exports to SSR init value, since user should never change its value. Why did some mPCIe cards not work? RouterBoot leaves USB port power and mPCIe port power lines on the Serial Shift Register =1. In ar71xx firmware doesn't touch them - ssr has the same intial values in march init code. In ath79 we have a DTS instead, where gpio-export is used. When SSR has no explicit default value, it uses 0 and there is a short period when mPCIe and USP power lines are =0 (till gpio-export reasserts them). And MikroTik mPCIe Wi-Fi 5Hz card R11e-5HacT doesn't work: PCI driver when starts logs warning: "PCIe link is down", lspci shows no device, rescan (echo 1 > /sys/bus/pci/rescan) doesn't work. PCI controller (arch/mips/pci-ar724x) starts... and says: "PCIe link is down", remembers this in the internal link_up field and never re-check AR724x_PCI_RESET_LINK_UP register bit. When link_up is false, pci read/write handlers always return error. When I patched it to actually check link status before reading, I had kernel panic with Device bus error when trying to read Vendor ID from config register (see "MIPS: pci-ar724x: avoid data bus error due to a missing PCIe module" Gabor Juhos patch). It seems that we need to somehow reinit the PCI host controller. Or init it after gpio-exports. Or simply don't touch mPCIe power. We prefer the last option. Acknowledgments: Koen Vandeputte Reported-by: Thomas Hühn Signed-off: Denis Kalashnikov --- ...9342_mikrotik_routerboard-912uag-2hpnd.dts | 14 ++++++------- .../451-gpio-74x164-init-val-support.patch | 20 +++++++++++++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 target/linux/ath79/patches-5.10/451-gpio-74x164-init-val-support.patch diff --git a/target/linux/ath79/dts/ar9342_mikrotik_routerboard-912uag-2hpnd.dts b/target/linux/ath79/dts/ar9342_mikrotik_routerboard-912uag-2hpnd.dts index 77a0d29113..b8dbe8b784 100644 --- a/target/linux/ath79/dts/ar9342_mikrotik_routerboard-912uag-2hpnd.dts +++ b/target/linux/ath79/dts/ar9342_mikrotik_routerboard-912uag-2hpnd.dts @@ -107,12 +107,6 @@ gpio-export { compatible = "gpio-export"; - beeper { - gpio-export,name = "beeper"; - gpio-export,output = <1>; /* Must be 1 to avoid EMI induced clicking noise */ - gpios = <&ssr 5 GPIO_ACTIVE_HIGH>; - }; - usb_power { gpio-export,name = "power-usb"; gpio-export,output = <1>; @@ -121,7 +115,7 @@ pcie_power { gpio-export,name = "power-pcie"; - gpio-export,output = <0>; + gpio-export,output = <1>; gpios = <&ssr 7 GPIO_ACTIVE_HIGH>; }; }; @@ -175,6 +169,12 @@ registers-number = <1>; reg = <1>; spi-max-frequency = <50000000>; + + /* + bit 7 -- pcie_power, bit 6 -- usb_power, bit 5 -- beeper + power (must be 1 to avoid EMI induced clicking noise) + */ + init-data = /bits/ 8 <0xe0>; }; }; diff --git a/target/linux/ath79/patches-5.10/451-gpio-74x164-init-val-support.patch b/target/linux/ath79/patches-5.10/451-gpio-74x164-init-val-support.patch new file mode 100644 index 0000000000..9dabb181b5 --- /dev/null +++ b/target/linux/ath79/patches-5.10/451-gpio-74x164-init-val-support.patch @@ -0,0 +1,20 @@ +--- a/drivers/gpio/gpio-74x164.c ++++ b/drivers/gpio/gpio-74x164.c +@@ -145,6 +145,17 @@ static int gen_74x164_probe(struct spi_d + chip->gpio_chip.parent = &spi->dev; + chip->gpio_chip.owner = THIS_MODULE; + ++ /* ++ * Read optional inital value of registers. First byte -- last register. ++ * E.g. init-data = /bits/ 8 <0x01 0x1f 0x02>; ++ */ ++ ret = of_property_read_u8_array(spi->dev.of_node, "init-data", ++ (u8 *)chip->buffer, (size_t)nregs); ++ if (ret && ret != -EINVAL /* Not found */) { ++ dev_err(&spi->dev, "Invalid 'init-data' property.\n"); ++ return -EINVAL; ++ } ++ + mutex_init(&chip->lock); + + ret = __gen_74x164_write_config(chip);