From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D46A4C433F5 for ; Fri, 5 Nov 2021 21:46:21 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 2F85C61101 for ; Fri, 5 Nov 2021 21:46:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2F85C61101 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5FF9782EBB; Fri, 5 Nov 2021 22:46:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org 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=sholland.org header.i=@sholland.org header.b="kikt7VaB"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="CB4tQnPA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BBE7D83741; Fri, 5 Nov 2021 22:46:17 +0100 (CET) Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DEE518373A for ; Fri, 5 Nov 2021 22:46:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 9C0155C0060; Fri, 5 Nov 2021 17:46:11 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Fri, 05 Nov 2021 17:46:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= to:cc:references:from:subject:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=V +TzdFa4JZ6KA8Xld7QiZOQ6ZnT6kGANUGwqXRnv1kE=; b=kikt7VaBXmOSmcPOS qLl6OmPEtBBgIeHIJXzf/DnuRdM22qbTn44qhpJ3Lfue9OUzYXqZ8GqwuaPJqcya au7s3CRgH0EpxhGywEYcq0Y3fybYRDTFnZEqGBilp5wIxpAjmuZEqL2Sqj58JfO2 MKUVkAZ/bScZkMdSf6ioqZFLAHX1kEf5YJTTOLE2mH32uSgjxuj2mFgz1tdSL9tB 5Sdi+dSYCLToc7fVl1YnTjCYsCRE88qJWgERwV0yoFTWUBEyGCgyvkxmDIUeyLQN i9XHkTOwadNt9CbYG3nu7mkFv9SzXqvXR6LqkCmPfAEheaIFIPDZq9U5AsNVC63o uJCmQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=V+TzdFa4JZ6KA8Xld7QiZOQ6ZnT6kGANUGwqXRnv1 kE=; b=CB4tQnPA/dkMiAnj0cRwVXB25kvT6TaG9+Zaa5cSgxTWpWPg8Dzgm9ORS 99z3vJgoTBmy3Kok30emG081cZuawPtyX/B6HEYU97DhABcDAsJnI5bxVrJYA6+e cTvxqsNL6R/XKl2ocKjbmH8abISoR3CT3S7Pi6eGbf9zTpp1vUpZ+/sGkMT49hzx UEzvaM/I5GgrcJC7+IbZfWxjRwIfaMowcD8gR6cTbuKkBTpvhHXvH7WHwOt6T50J mrzR0wPIZFFoDfd1rb5Y79prgi61I5l5s8i8LAHfhN8vkTqIHMgq7wnLE2zXW5WY KSwgj1OK4l0DdaCgMMouUjWy8m5xg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrtdeigdduhedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepvfhfhffukffffgggjggtgfesthekredttdefjeenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepvddttdejieduudfgffevteekffegffeguddtgfefkeduvedukeff hedtfeevuedvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 Nov 2021 17:46:09 -0400 (EDT) To: Heinrich Schuchardt Cc: Andy Shevchenko , Icenowy Zheng , Jaehoon Chung , Jernej Skrabec , Peng Fan , Simon Glass , u-boot@lists.denx.de, Jagan Teki , Andre Przywara References: <20211021045258.30757-1-samuel@sholland.org> <20211021045258.30757-4-samuel@sholland.org> From: Samuel Holland Subject: Re: [PATCH 3/4] gpio: sunxi: Implement .set_flags Message-ID: <8f46da6f-461c-a3ea-3486-5bc9fc6e13c6@sholland.org> Date: Fri, 5 Nov 2021 16:46:07 -0500 User-Agent: Mozilla/5.0 (X11; Linux ppc64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On 11/5/21 9:43 AM, Heinrich Schuchardt wrote: > On 10/21/21 06:52, Samuel Holland wrote: >> This, along with gpio_flags_xlate(), allows the GPIO driver to handle >> pull-up/down flags provided by consumer drivers or in the device tree. >> >> Signed-off-by: Samuel Holland >> Reviewed-by: Simon Glass >> --- >> >>   drivers/gpio/sunxi_gpio.c | 62 +++++++++++++++++---------------------- >>   1 file changed, 27 insertions(+), 35 deletions(-) >> >> diff --git a/drivers/gpio/sunxi_gpio.c b/drivers/gpio/sunxi_gpio.c >> index cdbc40d48f..92fee0118d 100644 >> --- a/drivers/gpio/sunxi_gpio.c >> +++ b/drivers/gpio/sunxi_gpio.c >> @@ -139,27 +139,6 @@ int sunxi_name_to_gpio(const char *name) >>       return ret ? ret : gpio; >>   } >>   -static int sunxi_gpio_direction_input(struct udevice *dev, unsigned >> offset) >> -{ >> -    struct sunxi_gpio_plat *plat = dev_get_plat(dev); >> - >> -    sunxi_gpio_set_cfgbank(plat->regs, offset, SUNXI_GPIO_INPUT); >> - >> -    return 0; >> -} >> - >> -static int sunxi_gpio_direction_output(struct udevice *dev, unsigned >> offset, >> -                       int value) >> -{ >> -    struct sunxi_gpio_plat *plat = dev_get_plat(dev); >> -    u32 num = GPIO_NUM(offset); >> - >> -    sunxi_gpio_set_cfgbank(plat->regs, offset, SUNXI_GPIO_OUTPUT); >> -    clrsetbits_le32(&plat->regs->dat, 1 << num, value ? (1 << num) : 0); >> - >> -    return 0; >> -} >> - >>   static int sunxi_gpio_get_value(struct udevice *dev, unsigned offset) >>   { >>       struct sunxi_gpio_plat *plat = dev_get_plat(dev); >> @@ -172,16 +151,6 @@ static int sunxi_gpio_get_value(struct udevice >> *dev, unsigned offset) >>       return dat & 0x1; >>   } >>   -static int sunxi_gpio_set_value(struct udevice *dev, unsigned offset, >> -                int value) >> -{ >> -    struct sunxi_gpio_plat *plat = dev_get_plat(dev); >> -    u32 num = GPIO_NUM(offset); >> - >> -    clrsetbits_le32(&plat->regs->dat, 1 << num, value ? (1 << num) : 0); >> -    return 0; >> -} >> - >>   static int sunxi_gpio_get_function(struct udevice *dev, unsigned >> offset) >>   { >>       struct sunxi_gpio_plat *plat = dev_get_plat(dev); >> @@ -205,18 +174,41 @@ static int sunxi_gpio_xlate(struct udevice *dev, >> struct gpio_desc *desc, >>       if (ret) >>           return ret; >>       desc->offset = args->args[1]; >> -    desc->flags = args->args[2] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW >> : 0; >> +    desc->flags = gpio_flags_xlate(args->args[2]); >> + >> +    return 0; >> +} >> + >> +static int sunxi_gpio_set_flags(struct udevice *dev, unsigned int >> offset, >> +                ulong flags) >> +{ >> +    struct sunxi_gpio_plat *plat = dev_get_plat(dev); >> + >> +    if (flags & GPIOD_IS_OUT) { >> +        u32 value = !!(flags & GPIOD_IS_OUT_ACTIVE); >> +        u32 num = GPIO_NUM(offset); >> + >> +        clrsetbits_le32(&plat->regs->dat, 1 << num, value << num); >> +        sunxi_gpio_set_cfgbank(plat->regs, offset, SUNXI_GPIO_OUTPUT); >> +    } else if (flags & GPIOD_IS_IN) { >> +        u32 pull = 0; >> + >> +        if (flags & GPIOD_PULL_UP) >> +            pull = 1; >> +        else if (flags & GPIOD_PULL_DOWN) >> +            pull = 2; >> +        sunxi_gpio_set_pull_bank(plat->regs, offset, pull); >> +        sunxi_gpio_set_cfgbank(plat->regs, offset, SUNXI_GPIO_INPUT); >> +    } >>         return 0; >>   } >>     static const struct dm_gpio_ops gpio_sunxi_ops = { >> -    .direction_input    = sunxi_gpio_direction_input, >> -    .direction_output    = sunxi_gpio_direction_output, > > Removing these operations is not related to your commit message. > > dm_gpio_set_value() seems to be using them. It does not use any of these operations when set_flags is provided. The same applies to _dm_gpio_set_flags(). asm-generic/gpio.h says about set_flags: > This method is required and should be implemented by new drivers. At > some point, it will supersede direction_input() and > direction_output(), which wil be removed. So I believe it is intended to replace the other three operations. Regards, Samuel >>       .get_value        = sunxi_gpio_get_value, >> -    .set_value        = sunxi_gpio_set_value, > > Same here. > > Best regards > > Heinrich > >>       .get_function        = sunxi_gpio_get_function, >>       .xlate            = sunxi_gpio_xlate, >> +    .set_flags        = sunxi_gpio_set_flags, >>   }; >>     /** >> >