Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 91634C433EF for ; Tue, 22 Feb 2022 09:23:13 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2AE3083C24; Tue, 22 Feb 2022 10:23:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=googlemail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=googlemail.com header.i=@googlemail.com header.b="QOrNpFz/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 20DB383C84; Tue, 22 Feb 2022 10:23:09 +0100 (CET) Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9892383C24 for ; Tue, 22 Feb 2022 10:23:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=googlemail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=chf.fritz@googlemail.com Received: by mail-ej1-x633.google.com with SMTP id p15so40790728ejc.7 for ; Tue, 22 Feb 2022 01:23:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=message-id:subject:from:reply-to:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=Hk0W8tgCtbwVKcvhkZkNSBanbKkXoYLq9Z9UZdqukBE=; b=QOrNpFz/e0X/MoBAS7KsdnJJsPkkA8Tnz/jLjtugdsr7beV+hu77I2eh/tzZlQToIT ROSte2n5hWDS15vJ2gNP8NoshMEPe/JkBH43F4XW0Bl3ay9vw/+N23E+K40BPVQ0eWkR iwcHOUhFM6phMGxWUJFdzW5K9bztJW+QpfNUMj8qWn87Lmu5WNR1eDJTGRjLQbvb68dp lCVp3WSTxQqxCMhp4wCEyrfeBKirIzcSn+xfryNCwFenSubhZcaGSbg/0Nsz+4kFvM49 2H3aUh65VpdSX/+9oJ+lfWc06Qr/zIUnLXAQ/VnqrmYFTqGi0VChNlBvo/5ExczwxALb 5acw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:reply-to:to:cc:date :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=Hk0W8tgCtbwVKcvhkZkNSBanbKkXoYLq9Z9UZdqukBE=; b=hPIcqAz1tBn5uG6qEuNpSs+nZ12WEfwP2zR6I9kG0l4G7YtIv3i6VGzGufMiTV0jGL hMzfAInXSldd6Ah/JUj83/SBynrQ9oGp2vd/S+Wq0DIKi7//hvOi/wyGfTTilQewGAb1 8F0FGVHv6e6ZXDsHZQT8yWx1alTowDX/b02sySo2qstOF+eIYPTN5+vFLm9DyVEQVYfy hpqoCk8+jNGWlyoaF/Go+CwJjGWlDLwjhqHEay8rdsGWrv4UXx4+73AMwD4QrDarm6VL RfaKA89a952doWi5Tztjbus1gBcz2y11jIgpcQUaPGmSS/HXao5UOtgZzSa/S++/dKnq p1FA== X-Gm-Message-State: AOAM532uATKZgGpiJuYwZcsEAnPam3CEjEw8B8w5SHkkSKWdS7ctQZ+Q ICK2kMMpVGPCyd8EiBR8Afk= X-Google-Smtp-Source: ABdhPJzDW56urlltLXH37t1QSNDsUi2VBz+nAnigLBjA7NA/6fjwjpHqrtQX2EJOxiW+0WShtqYYpg== X-Received: by 2002:a17:906:3c1a:b0:6ce:c404:9e3 with SMTP id h26-20020a1709063c1a00b006cec40409e3mr18343020ejg.454.1645521785099; Tue, 22 Feb 2022 01:23:05 -0800 (PST) Received: from mars.fritz.box ([2a02:8070:bb0:8700:3e7c:3fff:fe20:2cae]) by smtp.gmail.com with ESMTPSA id w4sm10019899edc.73.2022.02.22.01.23.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Feb 2022 01:23:04 -0800 (PST) Message-ID: <4ca0c13890d344b7795b23d59ca2ab2a28b09ffa.camel@googlemail.com> Subject: Re: [PATCH] gpio: rgpio2p: Enhance reading of GPIO pin value From: Christoph Fritz To: Fabio Estevam , "NXP i.MX U-Boot Team" Cc: U-Boot-Denx , NXP Linux Team , Stefano Babic Date: Tue, 22 Feb 2022 10:23:03 +0100 In-Reply-To: References: <1fe3fadd8f669058ad737c32b7af5d2c6ccb189e.camel@googlemail.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: chf.fritz@googlemail.com Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean *ping*, any objections getting this patch applied? On Mon, 2022-01-24 at 17:51 -0300, Fabio Estevam wrote: > On Mon, Jan 24, 2022 at 5:50 PM Fabio Estevam > wrote: > > > > [Adding the NXP folks to help reviewing it] > > Sorry, added the NXP Linux folks instead of the NXP U-Boot folks. > > > > > On Mon, Jan 24, 2022 at 5:46 PM Christoph Fritz > > wrote: > > > > > > Add support for reading GPIO pin value when function is output. > > > With this patch applied, gpio toggle command is working. > > > > > > Signed-off-by: Christoph Fritz > > > --- > > >  drivers/gpio/imx_rgpio2p.c | 14 +++++++++++++- > > >  1 file changed, 13 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/gpio/imx_rgpio2p.c > > > b/drivers/gpio/imx_rgpio2p.c > > > index 0e2874ca95c..175e460aff5 100644 > > > --- a/drivers/gpio/imx_rgpio2p.c > > > +++ b/drivers/gpio/imx_rgpio2p.c > > > @@ -39,6 +39,14 @@ static int imx_rgpio2p_is_output(struct > > > gpio_regs *regs, int offset) > > >         return val & (1 << offset) ? 1 : 0; > > >  } > > > > > > +static int imx_rgpio2p_bank_get_direction(struct gpio_regs > > > *regs, int offset) > > > +{ > > > +       if ((readl(®s->gpio_pddr) >> offset) & 0x01) > > > +               return IMX_RGPIO2P_DIRECTION_OUT; > > > + > > > +       return IMX_RGPIO2P_DIRECTION_IN; > > > +} > > > + > > >  static void imx_rgpio2p_bank_direction(struct gpio_regs *regs, > > > int offset, > > >                                     enum imx_rgpio2p_direction > > > direction) > > >  { > > > @@ -67,7 +75,11 @@ static void imx_rgpio2p_bank_set_value(struct > > > gpio_regs *regs, int offset, > > > > > >  static int imx_rgpio2p_bank_get_value(struct gpio_regs *regs, > > > int offset) > > >  { > > > -       return (readl(®s->gpio_pdir) >> offset) & 0x01; > > > +       if (imx_rgpio2p_bank_get_direction(regs, offset) == > > > +           IMX_RGPIO2P_DIRECTION_IN) > > > +               return (readl(®s->gpio_pdir) >> offset) & > > > 0x01; > > > + > > > +       return (readl(®s->gpio_pdor) >> offset) & 0x01; > > >  } > > > > > >  static int  imx_rgpio2p_direction_input(struct udevice *dev, > > > unsigned offset) > > > -- > > > 2.30.2 > > > > > > > > >