Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp244760pxu; Tue, 5 Jan 2021 09:42:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2puaumO9xCZuOTuDDa8Dn3YeceUcrhzXcmtY3F0ci/vCJaZbds3SSTtW2TiS1MSVgxbZU X-Received: by 2002:a17:906:e250:: with SMTP id gq16mr231389ejb.382.1609868521399; Tue, 05 Jan 2021 09:42:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609868521; cv=none; d=google.com; s=arc-20160816; b=LOa8HrXdo0g26+JeDplQRYDBcWRsh1vXcu/Pe7oppD899CCgDHKIYlTkKALC1SVHT6 dIejak/GA/Fp+jMzIlzvqjvZsfHJhAw2fU/DPKIl9ZoY4ux3cEek7BaNzqHEcddKfwa7 7wpkf1x3v8YKP1eKYGTBx5eTyIL+HiQWpCri+U0Gs3NUT5hSEDaINBm4EunfjIoj+VMu 0UCkYMaKbLGfGhnPnqbp+OfMTlpqUCC4H1JZWzWKcK9/VNKJTusj2LacIJeENclJOn4q 75zdS4XjONfaXpMOLe5O0cTFfKKfP90rVrXBF0qSLQnqx7iCcQkejwjUo5mRiyhRINHe Gavg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=KWt7Z7nj5fnpVzsa9K1vPpco4+qBE5NY/g/JbrcmWFU=; b=auKROk12IzZG2Rs9yPbjirm5Tdk9iG2JsRkrA42137X9prhB304YWR2w3QmAp0vgOm M5n1YBqvrejTxgDmiDBWV6ZOA93cfrcAqBS2/C2JfoQuVecyRSCGUYc7wKsh6jdTXgVd Yugm44cDGDvOTNZ6PHdT0vBkasFRMosVg3/90nbPLG2RqxlxagVGDvbkQXa1RNALtsp/ 3v6sA1/x0etQYN9QroLTAuc54fwjneX95D711ohLLb2mtIztH772snR5gq721bKcVWrE /lIFrRHZT/qijUOCRrPuecNVicsWCS3vkrVEPT6m/yxl6tXY4EVAggprlrJhEjrJ44mE rXPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@lechnology.com header.s=default header.b=YnDkq2sE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ce20si125828edb.138.2021.01.05.09.41.37; Tue, 05 Jan 2021 09:42:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@lechnology.com header.s=default header.b=YnDkq2sE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730542AbhAERhz (ORCPT + 99 others); Tue, 5 Jan 2021 12:37:55 -0500 Received: from vern.gendns.com ([98.142.107.122]:59106 "EHLO vern.gendns.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729419AbhAERhz (ORCPT ); Tue, 5 Jan 2021 12:37:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lechnology.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=KWt7Z7nj5fnpVzsa9K1vPpco4+qBE5NY/g/JbrcmWFU=; b=YnDkq2sEJEHSEewppiiReTFX0B l+Fz3fskqFNDNRADJyxsP34DmZHNxYB9OU804pNxv0iWzZwzfs971jHnDpCou1HviCgk5i/sUdeYp iynL9iM3DJcRC3yBfsunjCv2v6zaHPTDlqa5W56bPSkTa0QJo6fUeaYoob6/blyEZtlfDYA35TCBO RRhCKfaxLUPCPt+tTdUBXAZC/cZhpZ4REzB0VQwiOrGw7nTaiW0fQHXq3INX0MtxuaKVZJXncQ3FZ nIDFogujewo5E2xz7T0agqETwRuBD2IRvpME0Z6cCaoEQOANCyQuGeZTa9YbAmW4cMH9gLcQQWxrv G9srlAjQ==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:39598 helo=[192.168.0.134]) by vern.gendns.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1kwqGd-00026C-UC; Tue, 05 Jan 2021 12:37:12 -0500 Subject: Re: [PATCH] irqchip/irq-pruss-intc: implement set_type() callback To: Marc Zyngier Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , Suman Anna , Grzegorz Jaszczyk , Sekhar Nori , Bartosz Golaszewski , linux-arm-kernel@lists.infradead.org References: <20210104183656.333256-1-david@lechnology.com> <02075e85faa562e19b3aeccd53635cbc@kernel.org> From: David Lechner Message-ID: Date: Tue, 5 Jan 2021 11:37:09 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <02075e85faa562e19b3aeccd53635cbc@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/5/21 2:47 AM, Marc Zyngier wrote: > On 2021-01-04 18:36, David Lechner wrote: >> This implements the irqchip set_type() callback for the TI PRUSS >> interrupt controller. This is needed for cases where an event needs >> to be active low. >> >> According to the technical reference manual, the polarity should always >> be set to high, however in practice, the polarity needs to be set low >> for the McASP Tx/Rx system event in conjunction with soft UART PRU >> firmware for TI AM18XX SoCs, otherwise it doesn't work. > > I remember asking about this when I reviewed the patch series, and > was told that there was no need to handle anything *but* level high. > As a consequence, the DT binding doesn't have any way to express > the trigger configuration. > > Now this? What is going to drive the configuration? I made it work by setting IRQF_TRIGGER_LOW in devm_request_irq(). I can try to see if there is a way to change the (10 year old) firmware instead. Hopefully someone from TI can shed more light on the subject? > >> >> Signed-off-by: David Lechner >> --- >>  drivers/irqchip/irq-pruss-intc.c | 27 +++++++++++++++++++++++++++ >>  1 file changed, 27 insertions(+) >> >> diff --git a/drivers/irqchip/irq-pruss-intc.c b/drivers/irqchip/irq-pruss-intc.c >> index 5409016e6ca0..f882af8a7ded 100644 >> --- a/drivers/irqchip/irq-pruss-intc.c >> +++ b/drivers/irqchip/irq-pruss-intc.c >> @@ -334,6 +334,32 @@ static void pruss_intc_irq_unmask(struct irq_data *data) >>      pruss_intc_write_reg(intc, PRU_INTC_EISR, hwirq); >>  } >> >> +static int pruss_intc_irq_set_type(struct irq_data *data, unsigned int type) >> +{ >> +    struct pruss_intc *intc = irq_data_get_irq_chip_data(data); >> +    u32 reg, bit, val; >> + >> +    if (type & IRQ_TYPE_LEVEL_MASK) { >> +        /* polarity register */ >> +        reg = PRU_INTC_SIPR(data->hwirq / 32); >> +        bit = BIT(data->hwirq % 32); >> +        val = pruss_intc_read_reg(intc, reg); >> + >> +        /* >> +         * This check also ensures that IRQ_TYPE_DEFAULT will result >> +         * in setting the level to high. >> +         */ >> +        if (type & IRQ_TYPE_LEVEL_HIGH) >> +            val |= bit; >> +        else >> +            val &= ~bit; >> + >> +        pruss_intc_write_reg(intc, reg, val); > > RMW  of a shared register without locking? > >> +    } >> + >> +    return 0; > > What happens when this is passed an edge configuration? It should at > least return an error. This is probably a moot point if we are not going to allow changing the type, but there is another register for selecting edge or level. But the manual says similarly says it should always be set to level. > >> +} >> + >>  static int pruss_intc_irq_reqres(struct irq_data *data) >>  { >>      if (!try_module_get(THIS_MODULE)) >> @@ -389,6 +415,7 @@ static struct irq_chip pruss_irqchip = { >>      .irq_ack        = pruss_intc_irq_ack, >>      .irq_mask        = pruss_intc_irq_mask, >>      .irq_unmask        = pruss_intc_irq_unmask, >> +    .irq_set_type        = pruss_intc_irq_set_type, >>      .irq_request_resources    = pruss_intc_irq_reqres, >>      .irq_release_resources    = pruss_intc_irq_relres, >>      .irq_get_irqchip_state    = pruss_intc_irq_get_irqchip_state, > > Thanks, > >         M.