From patchwork Fri Jan 15 14:04:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1427041 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=jURkPS+1; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DHNHR47Kkz9tD5 for ; Sat, 16 Jan 2021 01:05:21 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4065582409; Fri, 15 Jan 2021 15:05:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="jURkPS+1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DF39382483; Fri, 15 Jan 2021 15:05:10 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) (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 6E44E8236C for ; Fri, 15 Jan 2021 15:05:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd33.google.com with SMTP id n2so1122533iom.7 for ; Fri, 15 Jan 2021 06:05:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dOz75kC1pmLBovza3/e0GIYP1qBAkSCggkCT0UJeGwY=; b=jURkPS+16pS82dcIRX3dKb3Qs5VW42jgL3OmUgGwMpXTheghDptct9qzcwEL2DsUct xxNFfnTUu7TcVOzvsF8Xh4yK0TZ8r7c2FuacloxCcGFzAxfQTwmr4C5ZFGlX2netDGf5 kf3039juL6dqzkeKwsaKnJNUtDTmhCJqgiSUE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dOz75kC1pmLBovza3/e0GIYP1qBAkSCggkCT0UJeGwY=; b=EQecK99FIQqavLtYJhFcwf63t40wCocDA8YJwwCTW/ikP0iYXAtIbFqT5wcrGDz28n Ct5Fa2ERbrmsyJ9p9hpyua4GBEwFowYBioGsL+OsEVwTqpMs6OswJdSx+KOQ7YrZF/n7 ol7zb/kuAiZiZ6Fp/lpH7ap7MqdaDR/CXgX3oDtGW/mMRxUzsHj3KTXd3ywvunM4CYgD zo7latQXw8sqfi8uM9JHEU45zhIzEbU9r/kzejFxnUGH/ww3CdDwFD1PbEluCvlQyuM5 Usm5vbdORLSmB1skYWBFyypabtdLsbRjlchZFop5nOXx1F3Q9GecM/lsIgR/vcF29BJJ 2MfA== X-Gm-Message-State: AOAM530kNBnBv7q4QfbUVijMjt5Am9nc7DxcofRDfHV1Z3R/2338FNRO Wenz5D+3+jwusZqc//9DJAdCHQLxG0ogSDIC X-Google-Smtp-Source: ABdhPJzFo66y05DP45sdXPUflJsykVimVDwM6iXQ8OZmnL4UDpd61urnipx081TEBWzv/Gj2/pm/Zg== X-Received: by 2002:a05:6638:d8a:: with SMTP id l10mr4834602jaj.2.1610719505704; Fri, 15 Jan 2021 06:05:05 -0800 (PST) Received: from localhost.localdomain (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id 1sm5664843ilv.37.2021.01.15.06.05.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 06:05:04 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Patrick Delaunay , Tom Rini , Simon Glass , Andy Shevchenko , Bin Meng , Dario Binacchi , Heiko Schocher , Jean-Jacques Hiblot , Marek Vasut , Patrice Chotard , Patrick Delaunay , Pavel Herrmann , Pratyush Yadav , Walter Lozano , Wolfgang Wallner , uboot-stm32@st-md-mailman.stormreply.com Subject: [PATCH 00/15] gpio: Update and simplify the uclass API Date: Fri, 15 Jan 2021 07:04:45 -0700 Message-Id: <20210115140500.846307-1-sjg@chromium.org> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-goog MIME-Version: 1.0 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.102.3 at phobos.denx.de X-Virus-Status: Clean At present the GPIO uclass mirrors what was in U-Boot before driver model. It works well in most cases but is becoming cumbersome with things like pull-up/down and drive strength. In those cases it is easier for the driver to deal with all the flags at one, rather than piece by piece. In fact the current API does not officially have a method for adjusting anything other than the direction flags. While set_dir_flags() and get_dir_flags() do in fact support changing other flags, this is not documented. Secondly, set_dir_flags actually ORs the current flags with the new ones so it is not possible to clear flags. It seems better to use a clr/set interface (bit clear followed by OR) to provide more flexibility. Finally, direction_input() and direction_output() are really just the same thing as set_dir_flags(), with a different name. We currently use the latter if available, failing back to the former. But it makes sense to deprecate the old methods. This series makes the above changes. Existing drivers are mostly left alone, since they should continue to operate as is. The sandbox driver is updated to add the required new tests and the x86 driver is switched over to the new API. The STM32 driver should be checked to make sure the open source/open drain features still work as intended. Simon Glass (15): gpio: Disable functions not used with of-platdata dm: gpio: Rename set_dir_flags() method to update_flags() dm: gpio: Rename get_dir_flags() method to get_flags() gpio: Rename dm_gpio_get_dir_flags() to dm_gpio_get_flags() gpio: Drop dm_gpio_set_dir() gpio: sandbox: Rename GPIO dir_flags to flags gpio: sandbox: Use a separate flag for the value gpio: sandbox: Fully separate pin value from output value gpio: sandbox: Make sandbox_gpio_set_flags() set all flags dm: gpio: Add a way to update flags gpio: Replace direction_input() and direction_output() gpio: Use an 'ops' variable everywhere gpio: x86: Drop the deprecated methods in intel_gpio gpio: sandbox: Track whether a GPIO is driven gpio: Add a way to read 3-way strapping pins arch/sandbox/include/asm/gpio.h | 17 +- arch/x86/include/asm/intel_pinctrl_defs.h | 5 + drivers/gpio/gpio-uclass.c | 228 ++++++++++++++----- drivers/gpio/intel_gpio.c | 72 +++--- drivers/gpio/sandbox.c | 137 ++++++++---- drivers/gpio/stm32_gpio.c | 14 +- drivers/pinctrl/pinctrl-stmfx.c | 14 +- include/asm-generic/gpio.h | 130 +++++++++-- test/dm/gpio.c | 261 +++++++++++++++++++--- 9 files changed, 663 insertions(+), 215 deletions(-)