Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2513985pxb; Fri, 29 Oct 2021 03:01:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIwHfGE3gG2eESGJyMScBOUuLmUI4PXi3/Ubb9KzG5/0OrQe1IESbp0Oj+uA/6yEGJfKFY X-Received: by 2002:a50:950b:: with SMTP id u11mr13871784eda.121.1635501699852; Fri, 29 Oct 2021 03:01:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635501699; cv=none; d=google.com; s=arc-20160816; b=JNhvCfR7uiDOrtA+FYe4IP5RUFpny2dIMgB450fC8uY9tE+IqlK3Lj6qaSGfttm5Xg Xnvgb1pzwi7ys91CEWliPkodM7r5GCBzuSF2nZL0FUpsuWnHzu3r3AU1IXqOhOOK80a+ 1NUgiLvXt1tkvGE9iELAS1SWnn3njHrfa7WKvW+J/zIg5eHoIvA7Vhpb3HRsVE8QG33q oEWxxeg8WG8XKdoS3ZZihy4iWfaX7EUY01zJlvEzip7AdEgngm5LXG4odAuNqTQFOr9m 0b2mgfhuZuDijDY4iey/NTyn4d+4UllFnY8naCquZnrhOA82a+UmXmV6ovtXvNfjHqmI bU/w== 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:dmarc-filter:sender:dkim-signature; bh=UnsNoYW7wP4F8KSJMq0q8k/qnjr/LOlMEp/wGWG3buI=; b=aI6nx8LEEf9yWjGVuhspc4/QYLl9s/KpQmPHIAQqOxRYnBPrNIFSFmIgm/c58BcMQ+ 95qvBSAf2spFr8PJ8s/Ut3fLvGw1b80mQsYtVa6o9EiAb+Cj/I1r4MnwVtMGCq0+v0J4 9fifk7/9DrpHRQ7aJjVz7S6kU/18TzbGoQ+s56CbEm9HW17kSRvzfoJVBN6bKPOfqTiw dxKKW9qzfSJy7dhj3alK/qUwv5Te3Qm3g7Htv9eZR7CqPb62y5VNXmzjWCUDrWSUJsbu ezekPa8p8KRsNSM1gtz8V9q3KgGxYwLdBmIZqx9vYvoQUlbYtEG68L8GQuLcofXBO1pU esUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=sFt9yTqR; 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 v8si8185037eda.402.2021.10.29.03.01.07; Fri, 29 Oct 2021 03:01:39 -0700 (PDT) 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=pass header.i=@mg.codeaurora.org header.s=smtp header.b=sFt9yTqR; 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 S231650AbhJ2KBe (ORCPT + 99 others); Fri, 29 Oct 2021 06:01:34 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:53590 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231610AbhJ2KBe (ORCPT ); Fri, 29 Oct 2021 06:01:34 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1635501545; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=UnsNoYW7wP4F8KSJMq0q8k/qnjr/LOlMEp/wGWG3buI=; b=sFt9yTqRXTegJ8SK23q9Iq9uN4G4TzFPQhMOSLz1B4N38ox25Z65JUY6qx7TYddpkOjVhJ1H cGMLPhEWKX+BivIMTK6IZtvqp3cKrz9Cy4XGjqvI/ZezFX6UfJTf+oTWWS0IFNLVSFKq8vvK FV2A3WiVfnVjN86HgbCVr08QzZs= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n05.prod.us-west-2.postgun.com with SMTP id 617bc5da648aeeca5c8222cd (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Fri, 29 Oct 2021 09:58:50 GMT Sender: rnayak=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id B5593C43460; Fri, 29 Oct 2021 09:58:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.4 required=2.0 tests=ALL_TRUSTED,BAYES_00, NICE_REPLY_A,SPF_FAIL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from [192.168.1.100] (unknown [49.207.214.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: rnayak) by smtp.codeaurora.org (Postfix) with ESMTPSA id DBEDBC4338F; Fri, 29 Oct 2021 09:58:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.codeaurora.org DBEDBC4338F Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=codeaurora.org Subject: Re: [PATCH v2 1/2] pinctrl: qcom: Add egpio feature support To: Bjorn Andersson Cc: agross@kernel.org, linus.walleij@linaro.org, linux-arm-msm@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, psodagud@codeaurora.org, dianders@chromium.org References: <1635250056-20274-1-git-send-email-rnayak@codeaurora.org> From: Rajendra Nayak Message-ID: <4fda39ce-189e-4873-dd40-3219c0052ffd@codeaurora.org> Date: Fri, 29 Oct 2021 15:28:44 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/29/2021 4:31 AM, Bjorn Andersson wrote: > On Tue 26 Oct 05:07 PDT 2021, Rajendra Nayak wrote: > >> From: Prasad Sodagudi >> >> egpio is a scheme which allows special power Island Domain IOs >> (LPASS,SSC) to be reused as regular chip GPIOs by muxing regular >> TLMM functions with Island Domain functions. >> With this scheme, an IO can be controlled both by the cpu running >> linux and the Island processor. This provides great flexibility to >> re-purpose the Island IOs for regular TLMM usecases. >> >> 2 new bits are added to ctl_reg, egpio_present is a read only bit >> which shows if egpio feature is available or not on a given gpio. >> egpio_enable is the read/write bit and only effective if egpio_present >> is 1. Once its set, the Island IO is controlled from Chip TLMM. >> egpio_enable when set to 0 means the GPIO is used as Island Domain IO. >> >> To support this we add a new function 'egpio' which can be used to >> set the egpio_enable to 0, for any other TLMM controlled functions >> we set the egpio_enable to 1. >> >> Signed-off-by: Prasad Sodagudi >> Signed-off-by: Rajendra Nayak >> --- >> drivers/pinctrl/qcom/pinctrl-msm.c | 17 +++++++++++++++-- >> drivers/pinctrl/qcom/pinctrl-msm.h | 4 ++++ >> 2 files changed, 19 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c >> index 8476a8a..bfdba3a 100644 >> --- a/drivers/pinctrl/qcom/pinctrl-msm.c >> +++ b/drivers/pinctrl/qcom/pinctrl-msm.c >> @@ -185,6 +185,7 @@ static int msm_pinmux_set_mux(struct pinctrl_dev *pctldev, >> unsigned int irq = irq_find_mapping(gc->irq.domain, group); >> struct irq_data *d = irq_get_irq_data(irq); >> unsigned int gpio_func = pctrl->soc->gpio_func; >> + unsigned int egpio_func = pctrl->soc->egpio_func; >> const struct msm_pingroup *g; >> unsigned long flags; >> u32 val, mask; >> @@ -218,8 +219,20 @@ static int msm_pinmux_set_mux(struct pinctrl_dev *pctldev, >> raw_spin_lock_irqsave(&pctrl->lock, flags); >> >> val = msm_readl_ctl(pctrl, g); >> - val &= ~mask; >> - val |= i << g->mux_bit; >> + >> + if (egpio_func && i == egpio_func) { >> + if (val & BIT(g->egpio_present)) >> + val &= ~BIT(g->egpio_enable); >> + else >> + return -EINVAL; > > You're returning here with pctrl->lock held and irqs disabled. argh, right. I will fix that and repost. I wonder if I should just drop that error handling completely, we wouldn't end up here unless the platform driver wrongly populates a pin which does not support egpio with a egpio function. > >> + } else { >> + val &= ~mask; >> + val |= i << g->mux_bit; >> + /* Check if egpio present and enable that feature */ > > I never remember if egpio_enable means apss or lpass, so I think this > comment would be better as: > > /* Claim ownership of pin if egpio capable */ :) makes sense > >> + if (egpio_func && (val & BIT(g->egpio_present))) > > Can't you drop the parenthesis around the second expression? yes, will do, thanks for the review. -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation