Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3451004pxb; Mon, 1 Nov 2021 14:06:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuTW//KECQXnrqqQG8Hety8iVimzVpD4Hv9nvAo7OziUl/XhWsXw31VWXUdpFX+qPqfvL4 X-Received: by 2002:a6b:db0d:: with SMTP id t13mr3518103ioc.171.1635800771690; Mon, 01 Nov 2021 14:06:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635800771; cv=none; d=google.com; s=arc-20160816; b=lHub5txaTZ2LW/etrqHNnCLbj6Ehay8J7d1sIGbNkfn4OAaXg9Kz8G5GsKLk42S2rN VUU36TD+nNLU+85jMhyKxU2KJXVlDGeiJl8b+Ite9zcAzFcqTkhmjvlIIUQtV8gDr4Zp AmihbCtvWDuaZJNKXT8/w6A5ihp+EoiibIGG0QM8QUG/QXOB9A1rlXFgeiGAUPCFc9T4 Y10arG3ayguwxlC5oB1f9wtdod0dj/0EnLoNVabIWKO3mSHoXeKsPn/IbFPKrj1viiyt Bt8ESSL+F2Cqx7iSwbn1mJxKY5ivL+382kLMjneC9hEoioBBfWZA6jDquP33NmTTvG8c VUUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=65jDPfBpqzh1SVGsQCqxZHrsT33rrJhILf2Fclkb08g=; b=KSXIN9AssZpogsedvC3btbHL0U6juaxceFC6qsDsXdxv1/5NOjCjjAhpxASuAv0tcH ABlwBolIJWB59OWrzKJhLERjnZkTbTGFPuSUyiF/vXii11di+6QaLmh1EUdnZOhprkFa kssniGXrQZh3XHpdoQpnwnmr7J9lAL76Y3sn2o/XKvWJ9vqIht0/ufeoLZvkzm+qA4hn HlQD/cmWW7BTnbP835lrk5zJhm1oOE9Lg6Vt7MUIzhWW1Q9hR6NtQYxOaCvvd+UrOlNl DBxXv72Wbfl1zAEouPyJ9uzfMsI9ul2VpTFc5F/qoHeWn0ETeZEeBLcs+ztch+e1SNvk 1qEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CDgNHzQh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m20si29844871jaj.97.2021.11.01.14.05.59; Mon, 01 Nov 2021 14:06:11 -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=@chromium.org header.s=google header.b=CDgNHzQh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229990AbhKAVHX (ORCPT + 99 others); Mon, 1 Nov 2021 17:07:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229738AbhKAVHX (ORCPT ); Mon, 1 Nov 2021 17:07:23 -0400 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61EA6C061764 for ; Mon, 1 Nov 2021 14:04:49 -0700 (PDT) Received: by mail-il1-x130.google.com with SMTP id s3so19929325ild.0 for ; Mon, 01 Nov 2021 14:04:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=65jDPfBpqzh1SVGsQCqxZHrsT33rrJhILf2Fclkb08g=; b=CDgNHzQhfNf1YPq2tYY+/T0WtRXHC1qbzcm3IQ3yj+OmPjRmzY8p1i/x714lGiB0lj 3XvAC7XW2LLwLqdemgGnmisO8yX0Z4RyURcFcLMNm940Y7hJBzjTiGyGSLFaFxAzXrWV WZ2IJWLlizZtfqHCSRiKmo/djbib8Qelp+vek= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=65jDPfBpqzh1SVGsQCqxZHrsT33rrJhILf2Fclkb08g=; b=2EhQqmJ++J73/uEDGJcWS+kPQpeBad7n7y6ZfOjhUCqK+LQ0gbuo3/AU7d1VaWWxU7 0olBMjex1/kBEubsSwAumkzs9DOm+fEBR3IazGxpC5bzrDW/s/8lgd6XMXUHGskSXpjE NxjTiuEbrhOScXfnaAk/wGr3GIb0GASdEr9BER9ZEaHSd+Esf7jS3YbTImFMKlX117Rf fhkVbHj7PF6GL28Hcqo2PNAwXLsXhLWFZj4R+KxvTHRZcX8HMBQ3XKbvt6ppWJZGyxkW 9/d4NrCbPd6cGucljQY3I9H4vbDirwq+zGacH/y3vKEXnKKPJ9bzqnwLgwUE6sqyJMG6 8KHg== X-Gm-Message-State: AOAM531C670uzsXZxUMx0V7N7rFKOVuvPLZpuLiM7nOtw6PL0cv0zNop PH4B02X2Kpye0ivdR0NT0AJ151rxcjwXsQ== X-Received: by 2002:a05:6e02:168c:: with SMTP id f12mr2256964ila.171.1635800688318; Mon, 01 Nov 2021 14:04:48 -0700 (PDT) Received: from mail-il1-f170.google.com (mail-il1-f170.google.com. [209.85.166.170]) by smtp.gmail.com with ESMTPSA id a14sm9113611ilv.86.2021.11.01.14.04.47 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Nov 2021 14:04:47 -0700 (PDT) Received: by mail-il1-f170.google.com with SMTP id i12so13645133ila.12 for ; Mon, 01 Nov 2021 14:04:47 -0700 (PDT) X-Received: by 2002:a05:6e02:1a67:: with SMTP id w7mr15354968ilv.165.1635800686977; Mon, 01 Nov 2021 14:04:46 -0700 (PDT) MIME-Version: 1.0 References: <1635250056-20274-1-git-send-email-rnayak@codeaurora.org> In-Reply-To: <1635250056-20274-1-git-send-email-rnayak@codeaurora.org> From: Doug Anderson Date: Mon, 1 Nov 2021 14:04:34 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/2] pinctrl: qcom: Add egpio feature support To: Rajendra Nayak Cc: Bjorn Andersson , Andy Gross , LinusW , linux-arm-msm , "open list:GPIO SUBSYSTEM" , LKML , Prasad Sodagudi Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Tue, Oct 26, 2021 at 5:09 AM 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; > + } else { > + val &= ~mask; > + val |= i << g->mux_bit; > + /* Check if egpio present and enable that feature */ > + if (egpio_func && (val & BIT(g->egpio_present))) > + val |= BIT(g->egpio_enable); > + } > + > msm_writel_ctl(val, pctrl, g); > > raw_spin_unlock_irqrestore(&pctrl->lock, flags); > diff --git a/drivers/pinctrl/qcom/pinctrl-msm.h b/drivers/pinctrl/qcom/pinctrl-msm.h > index e31a516..b7110ac 100644 > --- a/drivers/pinctrl/qcom/pinctrl-msm.h > +++ b/drivers/pinctrl/qcom/pinctrl-msm.h > @@ -77,6 +77,8 @@ struct msm_pingroup { > unsigned drv_bit:5; > > unsigned od_bit:5; > + unsigned egpio_enable:5; > + unsigned egpio_present:5; > unsigned oe_bit:5; > unsigned in_bit:5; > unsigned out_bit:5; > @@ -119,6 +121,7 @@ struct msm_gpio_wakeirq_map { > * to be aware that their parent can't handle dual > * edge interrupts. > * @gpio_func: Which function number is GPIO (usually 0). > + * @egpio_func: Which function number is eGPIO nit: in the above, document that this is actually a _virtual_ number. In other words it doesn't actually map to any real hardware register setting. Also maybe document 0 here means that eGPIO isn't supported on this SoC. ...and lastly, all the other entries in this docstring end with a ".". Something roughly like this: * @egpio_func: If non-zero then this SoC supports eGPIO. Even though in hardware this is a mux 1-level above the TLMM, we'll treat it as if this is just another mux state of the TLMM. Since it doesn't really map to hardware, we'll allocate a virtual function number for eGPIO and any time we see that function number used we'll treat it as a request to mux away from our TLMM towards another owner. Thinking about this made me look a little closer at your virtual function number, though. On sc7280 (in the next patch) you chose function "9" as GPIO. Things smell a little strange, though. Apparently sc7280 was already setup for a non-virtual "function 9" since "nfuncs" was 10. Was this just a fortunate bug that kept you from having to touch all the sc7280 PINGROUP definitions in the next patch, or is there actually a true "function 9" somewhere in the hardware that we might want to someday add to Linux? If so, should we pick eGPIO as 10? ...and then, looking further, what would happen if we picked eGPIO 10? Should "nfuncs" include this virtual number, or not? If "nfuncs" _does_ include this number and it bumps you over to the next "order_base_2" then the mask calculated by msm_pinmux_set_mux() will be wrong. If "nfuncs" _doesn't_ include this number then we should probably document that fact, and (I suppose) change sc7280's "nfuncs" down to 9? -Doug