Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1644732imu; Thu, 17 Jan 2019 00:36:01 -0800 (PST) X-Google-Smtp-Source: ALg8bN7H4CqhGEjAXhF3Y5dZhhdVlaOwBjT0pLhVI08kgMYFbNtVpy6OBhdIwsbyOHGzDVqvw1yQ X-Received: by 2002:a63:b0a:: with SMTP id 10mr12623856pgl.423.1547714161478; Thu, 17 Jan 2019 00:36:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547714161; cv=none; d=google.com; s=arc-20160816; b=nVuCHMS3c39y3Z/S7/US7yPmsjRk9eAdjzHVGRX0YGfPzcviwyw6KG4nUq6d8uivae 2gSbuay68W1clQKrPQ7LAhpwBRQOyvKCZbEvDg2dAD8k1V83Nr0GRsxuhxnshprmS1kC IJWQw7umnHl3HlmyA/xdvZnxlsQsyLeoh5+Rq7lzwbMANvlK1G+xsrD/nQCeSsYlv+2d 3dMUasn2j08URYa95JHMdQt/MgXxvMZ654x0f4SK9pxEJgWYBrsHiGTfYbvAApyr5OAQ 7zWwiGmUnxABxbLgMe+gISqpV/2PbH3TcDT1sudb//NF/vE4jPPDQ1JQCzwMqHAnf+xZ IIng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dmarc-filter:dkim-signature:dkim-signature; bh=9oCGnc5tCV9U/tOGBPivgKBVruSsFfv8NcicKosbXuk=; b=aXtQ8x8tid6hBDDjdoIXZ6I1gdEDst/ksBCi7ypcxagMDA9QMj8QrgNnVdbMwbSqNU 0MGtpZsQfq8K7xlKDpXmPj6UW+G7NWSolNzIzIDwyqyhyDTUW/IKd8cI/nXOpFMY5eer /2H29AMuX46YMTfS4+LQcRhwNhU8Ot26ZF7FkzbHE/etnuq7Z4H9uPHEgYLpP0wyYJF6 U6NnK3YlZjkJwCkXYCJmYalhGQC4WwhhALtbWM2p+xE/CWUoAj8Sa+6SQbOuvBFVd6u4 eCSS5D7rgQv4almvR920XjOM107mYQYhmCmvPbz2yJ19FmmWqNEyduDLE+htOQoaJyOM soPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=fG4IV6MF; dkim=pass header.i=@codeaurora.org header.s=default header.b=fG4IV6MF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 10si1135648pfy.206.2019.01.17.00.35.43; Thu, 17 Jan 2019 00:36:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=fG4IV6MF; dkim=pass header.i=@codeaurora.org header.s=default header.b=fG4IV6MF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388106AbfAPXNb (ORCPT + 99 others); Wed, 16 Jan 2019 18:13:31 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:58194 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726835AbfAPXNb (ORCPT ); Wed, 16 Jan 2019 18:13:31 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id D1EC560300; Wed, 16 Jan 2019 23:13:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1547680409; bh=wTvtcTx2T3WpJnVZtD3SM4QmaapVWUXKKXneT2PKIeQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fG4IV6MFqa/xyaws1ijMEIZHtf9h3WZKWX4FdfAQiaWwiVUI45kruzfxbwbW2gCsw aGQ2yJVxyi3/aK6GXHATaZm9/ZoeHal6UlO8193F4lkctWI8RB903Uip8xVk63eWP6 XwTwbVjzhrH5ZS5+HkLAqKes4ZuPGCbt/HtWS1NM= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED autolearn=no autolearn_force=no version=3.4.0 Received: from localhost (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: ilina@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id C03B96053B; Wed, 16 Jan 2019 23:13:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1547680409; bh=wTvtcTx2T3WpJnVZtD3SM4QmaapVWUXKKXneT2PKIeQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fG4IV6MFqa/xyaws1ijMEIZHtf9h3WZKWX4FdfAQiaWwiVUI45kruzfxbwbW2gCsw aGQ2yJVxyi3/aK6GXHATaZm9/ZoeHal6UlO8193F4lkctWI8RB903Uip8xVk63eWP6 XwTwbVjzhrH5ZS5+HkLAqKes4ZuPGCbt/HtWS1NM= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org C03B96053B Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=ilina@codeaurora.org Date: Wed, 16 Jan 2019 16:13:28 -0700 From: Lina Iyer To: Stephen Boyd Cc: evgreen@chromium.org, marc.zyngier@arm.com, linux-kernel@vger.kernel.org, rplsssn@codeaurora.org, linux-arm-msm@vger.kernel.org, thierry.reding@gmail.com, bjorn.andersson@linaro.org Subject: Re: [PATCH 5/7] drivers: pinctrl: msm: setup GPIO irqchip hierarchy Message-ID: <20190116231328.GA20369@codeaurora.org> References: <20181219221105.3004-1-ilina@codeaurora.org> <20181219221105.3004-6-ilina@codeaurora.org> <154533621302.79149.15228907259643696166@swboyd.mtv.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <154533621302.79149.15228907259643696166@swboyd.mtv.corp.google.com> User-Agent: Mutt/1.11.1 (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 20 2018 at 13:03 -0700, Stephen Boyd wrote: >Quoting Lina Iyer (2018-12-19 14:11:03) >> + >> +static int msm_gpio_domain_alloc(struct irq_domain *domain, unsigned int virq, >> + unsigned int nr_irqs, void *arg) >> +{ >> + int ret; >> + irq_hw_number_t hwirq; >> + struct gpio_chip *gc = domain->host_data; >> + struct msm_pinctrl *pctrl = gpiochip_get_data(gc); >> + struct irq_fwspec *fwspec = arg; >> + struct qcom_irq_fwspec parent = { }; >> + unsigned int type; >> + >> + ret = msm_gpio_domain_translate(domain, fwspec, &hwirq, &type); >> + if (ret) >> + return ret; >> + >> + ret = irq_domain_set_hwirq_and_chip(domain, virq, hwirq, >> + &pctrl->irq_chip, gc); >> + if (ret < 0) >> + return ret; >> + >> + if (!domain->parent) >> + return 0; >> + >> + parent.fwspec.fwnode = domain->parent->fwnode; >> + parent.fwspec.param_count = 2; >> + parent.fwspec.param[0] = hwirq; >> + parent.fwspec.param[1] = type; >> + >> + ret = irq_domain_alloc_irqs_parent(domain, virq, nr_irqs, &parent); >> + if (ret) >> + return ret; >> + >> + if (parent.mask) >> + set_bit(hwirq, pctrl->wakeup_masked_irqs); >> + >> + return 0; >> +} >> + >> +/* >> + * TODO: Get rid of this and push it into gpiochip_to_irq() > >Hmm.. yeah we need to do this still. I think we can have a generic two >cell function similar to irq_domain_xlate_twocell() that does the fwspec >creation and uses some of the things that we pass to >gpiochip_irqchip_add(), like the default level type. This existing >function is not good to have, so there's work to do to get rid of this. > >I was also thinking that maybe we can make the alloc function above take >a struct gpio_irq_fwspec structure that tells the alloc function what >gpiochip the irq is for. That would mean that we need to change the >gpio_to_irq() function below to be generic and stuff the chip inside the >fwspec wrapper structure: > > struct gpio_irq_fwspec { > struct irq_fwspec fwspec; > struct gpio_chip *chip; > unsigned int offset; > }; > >but I seem to recall that was not working for some reason. > I was thinking about this. If I understand you correctly, we want to generalize the .translate and .alloc functions. We could move the .translate to generic however, the alloc would still need to be specific for the parent.mask. But we can do this without the gpio_irq_fwspec. I presume you suggest this structure so we could pass the hwirq and type to the .alloc function. but we have that in the fwspec. What am I missing? >> + */ >> +static int msm_gpio_to_irq(struct gpio_chip *chip, unsigned int offset) >> +{ >> + struct irq_fwspec fwspec; >> + >> + fwspec.fwnode = of_node_to_fwnode(chip->of_node); >> + fwspec.param[0] = offset; >> + fwspec.param[1] = IRQ_TYPE_LEVEL_HIGH; >> + fwspec.param_count = 2; >> + >> + return irq_create_fwspec_mapping(&fwspec); >> +} >> + >> +static const struct irq_domain_ops msm_gpio_domain_ops = { >> + .translate = msm_gpio_domain_translate, >> + .alloc = msm_gpio_domain_alloc, >> + .free = irq_domain_free_irqs_top, >> +}; >> +