From patchwork Fri Jun 7 17:29:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniu Rosca X-Patchwork-Id: 10982489 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6324F6C5 for ; Fri, 7 Jun 2019 17:30:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 498C728ACB for ; Fri, 7 Jun 2019 17:30:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C0232884A; Fri, 7 Jun 2019 17:30:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44E7F28ACB for ; Fri, 7 Jun 2019 17:30:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731441AbfFGRal (ORCPT ); Fri, 7 Jun 2019 13:30:41 -0400 Received: from smtp1.de.adit-jv.com ([93.241.18.167]:42245 "EHLO smtp1.de.adit-jv.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729355AbfFGRal (ORCPT ); Fri, 7 Jun 2019 13:30:41 -0400 Received: from localhost (smtp1.de.adit-jv.com [127.0.0.1]) by smtp1.de.adit-jv.com (Postfix) with ESMTP id E50563C00DD; Fri, 7 Jun 2019 19:30:36 +0200 (CEST) Received: from smtp1.de.adit-jv.com ([127.0.0.1]) by localhost (smtp1.de.adit-jv.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gB7ra8XJGT9k; Fri, 7 Jun 2019 19:30:28 +0200 (CEST) Received: from HI2EXCH01.adit-jv.com (hi2exch01.adit-jv.com [10.72.92.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp1.de.adit-jv.com (Postfix) with ESMTPS id 177693C00D1; Fri, 7 Jun 2019 19:30:28 +0200 (CEST) Received: from vmlxhi-102.adit-jv.com (10.72.93.184) by HI2EXCH01.adit-jv.com (10.72.92.24) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 7 Jun 2019 19:30:27 +0200 From: Eugeniu Rosca To: Geert Uytterhoeven , Simon Horman , Kalle Valo , "David S. Miller" , Greg Kroah-Hartman , Randy Dunlap , Tony Lindgren , Ulf Hansson , John Stultz , , , , Spyridon Papageorgiou , Joshua Frkuska , "George G . Davis" , Andrey Gusakov , Linux-Renesas CC: Eugeniu Rosca , Eugeniu Rosca Subject: [PATCH] wlcore/wl18xx: Add invert-irq OF property for physically inverted IRQ Date: Fri, 7 Jun 2019 19:29:58 +0200 Message-ID: <20190607172958.20745-1-erosca@de.adit-jv.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Originating-IP: [10.72.93.184] Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The wl1837mod datasheet [1] says about the WL_IRQ pin: ---8<--- SDIO available, interrupt out. Active high. [..] Set to rising edge (active high) on powerup. ---8<--- That's the reason of seeing the interrupt configured as: - IRQ_TYPE_EDGE_RISING on HiKey 960/970 - IRQ_TYPE_LEVEL_HIGH on a number of i.MX6 platforms We assert that all those platforms have the WL_IRQ pin connected to the SoC _directly_ (confirmed on HiKey 970 [2]). That's not the case for R-Car Kingfisher extension target, which carries a WL1837MODGIMOCT IC. There is an SN74LV1T04DBVR inverter present between the WLAN_IRQ pin of the WL18* chip and the SoC, effectively reversing the requirement quoted from [1]. IOW, in Kingfisher DTS configuration we would need to use IRQ_TYPE_EDGE_FALLING or IRQ_TYPE_LEVEL_LOW. Unfortunately, v4.2-rc1 commit bd763482c82ea2 ("wl18xx: wlan_irq: support platform dependent interrupt types") made a special case out of these interrupt types. After this commit, it is impossible to provide an IRQ configuration via DTS which would describe an inverter present between the WL18* chip and the SoC, generating the need for workarounds like [3]. Create a boolean OF property, called "invert-irq" to specify that the WLAN_IRQ pin of WL18* is connected to the SoC via an inverter. This solution has been successfully tested on R-Car H3ULCB-KF-M06 using the DTS configuration [4] combined with the "invert-irq" property. [1] http://www.ti.com/lit/ds/symlink/wl1837mod.pdf [2] https://www.96boards.org/documentation/consumer/hikey/hikey970/hardware-docs/ [3] https://github.com/CogentEmbedded/meta-rcar/blob/289fbd4f8354/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas/0024-wl18xx-do-not-invert-IRQ-on-WLxxxx-side.patch [4] https://patchwork.kernel.org/patch/10895879/ ("arm64: dts: ulcb-kf: Add support for TI WL1837") Signed-off-by: Eugeniu Rosca --- drivers/net/wireless/ti/wl18xx/main.c | 5 +++++ drivers/net/wireless/ti/wlcore/sdio.c | 2 ++ drivers/net/wireless/ti/wlcore/wlcore_i.h | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c index 496b9b63cea1..cea91d1aee98 100644 --- a/drivers/net/wireless/ti/wl18xx/main.c +++ b/drivers/net/wireless/ti/wl18xx/main.c @@ -877,6 +877,8 @@ static int wl18xx_pre_boot(struct wl1271 *wl) static int wl18xx_pre_upload(struct wl1271 *wl) { + struct platform_device *pdev = wl->pdev; + struct wlcore_platdev_data *pdata = dev_get_platdata(&pdev->dev); u32 tmp; int ret; u16 irq_invert; @@ -932,6 +934,9 @@ static int wl18xx_pre_upload(struct wl1271 *wl) if (ret < 0) goto out; + if (pdata->invert_irq) + goto out; + ret = irq_get_trigger_type(wl->irq); if ((ret == IRQ_TYPE_LEVEL_LOW) || (ret == IRQ_TYPE_EDGE_FALLING)) { wl1271_info("using inverted interrupt logic: %d", ret); diff --git a/drivers/net/wireless/ti/wlcore/sdio.c b/drivers/net/wireless/ti/wlcore/sdio.c index 4d4b07701149..581f56b0b6a2 100644 --- a/drivers/net/wireless/ti/wlcore/sdio.c +++ b/drivers/net/wireless/ti/wlcore/sdio.c @@ -266,6 +266,8 @@ static int wlcore_probe_of(struct device *dev, int *irq, int *wakeirq, of_property_read_u32(np, "tcxo-clock-frequency", &pdev_data->tcxo_clock_freq); + pdev_data->invert_irq = of_property_read_bool(np, "invert-irq"); + return 0; } #else diff --git a/drivers/net/wireless/ti/wlcore/wlcore_i.h b/drivers/net/wireless/ti/wlcore/wlcore_i.h index 32ec121ccac2..01679f9d7170 100644 --- a/drivers/net/wireless/ti/wlcore/wlcore_i.h +++ b/drivers/net/wireless/ti/wlcore/wlcore_i.h @@ -213,6 +213,10 @@ struct wlcore_platdev_data { u32 ref_clock_freq; /* in Hertz */ u32 tcxo_clock_freq; /* in Hertz, tcxo is always XTAL */ bool pwr_in_suspend; + bool invert_irq; /* specify if there is a physical IRQ inverter + * between WL chip and SoC, like SN74LV1T04DBVR + * in case of R-Car Kingfisher board + */ }; #define MAX_NUM_KEYS 14