From patchwork Fri Dec 2 16:27:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Breathitt Gray X-Patchwork-Id: 630731 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20255C4321E for ; Fri, 2 Dec 2022 16:27:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232011AbiLBQ1Z (ORCPT ); Fri, 2 Dec 2022 11:27:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233858AbiLBQ1Y (ORCPT ); Fri, 2 Dec 2022 11:27:24 -0500 Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F38755A1 for ; Fri, 2 Dec 2022 08:27:23 -0800 (PST) Received: by mail-qt1-x832.google.com with SMTP id a4so1994678qtm.11 for ; Fri, 02 Dec 2022 08:27:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=gP/2RrbBINHs0AluywNvaZMiu07gERJD3ysXTDCWXck=; b=twtpopHQp0767kfvrjHHaajrLQU0rxdc8bCqpTfQWbnvgiS0g/ZDUt0fyZDlbZroIp 86OVRoZkw1NX+wHchEgzib54lmZxyEo9fSDuB2MS7+UoRyK0t3RUNr69fN0EbLlO8Ujt 3Jxk9fr9bDcfHxCRPUweUidhdxGdGcZ8Kck6M2ae13+8kMSpOdfEMmlHDA8vj2MQcFfL 9M52M2PCAishs8Sp6tMG0lAvA4Mn1btLMQ7isJwk5u30C+ktct8L8RHDHjpKK+ebl039 vphWVAu3nv7QmUYkHS58vzJZo3Xpdoza1E/iH8b0CeutedAplOT4fICrPofiKDOw3M28 fQ2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gP/2RrbBINHs0AluywNvaZMiu07gERJD3ysXTDCWXck=; b=5TQIS4HNcXWlTh3kPLzR2Y1gK9FeuVlWcD1w3ADkobA8Zy77bWNM6FqdZ5dgnkkymV Oin35N262M7jcOlNjcBINEUYnYG9lrxMLVYgxe9Eg+YeMbcCMQXRFBjpyLQF7gININ0M w00VwpaQ9md344DElx+Gf4kQ0+kZLM57D2y6lq9nf6BtudqAZ+Na9aomqjOmIEqxe4HS vsPrNXEHma4rpgnSpT/01+1swllHNTVFP9M8qPzpvoylYlAThEPCVRB+vNqnRwC7CzbK f3N83fmkW9gDcsD/kwA8XjD9Q6SIhga8zCWy5Zas36YYJoo0I89SqX5L+vZM1SUrhynm scrA== X-Gm-Message-State: ANoB5pkPhVXIwSE0ADI0jq14H0US82YR4EFrLAdbCA46Coqn1PLTifyU UMLhS2UpdlId5lakuqnKsOZ7FA== X-Google-Smtp-Source: AA0mqf6MR7ftSsfsq3Q9C1yEnOIwqAcQnSaFaSy8WPU63qQFCQPCJsHQSobZZlKPhxbbAHgz16oj7Q== X-Received: by 2002:ae9:ed47:0:b0:6fa:15e3:3507 with SMTP id c68-20020ae9ed47000000b006fa15e33507mr47613881qkg.673.1669998442334; Fri, 02 Dec 2022 08:27:22 -0800 (PST) Received: from fedora.attlocal.net (69-109-179-158.lightspeed.dybhfl.sbcglobal.net. [69.109.179.158]) by smtp.gmail.com with ESMTPSA id fp38-20020a05622a50a600b00343057845f7sm4391887qtb.20.2022.12.02.08.27.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 08:27:21 -0800 (PST) From: William Breathitt Gray To: linus.walleij@linaro.org, brgl@bgdev.pl Cc: andriy.shevchenko@linux.intel.com, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, michael@walle.cc, broonie@kernel.org, William Breathitt Gray Subject: [PATCH v4 0/9] Migrate i8255 GPIO drivers to regmap API Date: Fri, 2 Dec 2022 11:27:06 -0500 Message-Id: X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Changes in v4: - Align trailing '\' characters in macros to same column in 104-dio-48e and 104-idi-48 - Remove superfluous trailing commas in macros in 104-dio-48e and 104-idi-48 - Simplify dio48e_handle_mask_sync() regmap_* calls error checks to return error codes directly - Refactor dio48e_irq_init_hw() for regmap and comment about spurious interrupts; in theory this should be enough to prevent spurious interrupts before the system is ready, but we can pass this function as a callback where needed in the future - Cleanup '{0}' as '{}' in probe() callbacks for 104-dio-48e, 104-idi-48, and gpio-mm - Utilize dev_err_probe() in probe() callbacks for 104-dio-48e and 104-idi-48 - Provide convenience comments for idi48_regmap_irqs initialization list - Replace header includes with forward declarations in gpio-i8255.h The regmap API supports IO port accessors so we can take advantage of regmap abstractions rather than handling access to the device registers directly in the driver. The 104-dio-48e and gpio-mm modules depend on the i8255 library and are thus updated accordingly. The 104-IDI-48 is hardwired as an input-only device. Because the i8255 control registers are not exposed on the 104-IDI-48, the i8255 library doesn't provide much benefit here. In this case it's simpler to utilize the gpio_regmap API directly, so this patch series does such and removes the i8255 library dependency from the 104-idi-48 module. The first patch in this series adjusts gpio_regmap to always set gpio_chip get_direction. This patch is mostly independent of the rest of the patches in the series and can be picked up separately if desired. I'm including it here because it allows the input-only 104-idi-48 driver to continue reporting offset directions after migrating to gpio_regmap. A handle_mask_sync() callback is introduced for the regmap_irq API. This is used by the 104-dio-48e driver to handle its enable/disable interrupt functionality. The 104-DIO-48E has a single register to handle enabling/disabling interrupts: a write of any value to this register enables interrupts, while any read disables interrupts. By leveraging the gpio_regmap API, the i8255 library is reduced to simply a devm_i8255_regmap_register() function, a configuration structure struct i8255_regmap_config, and a helper macro i8255_volatile_regmap_range() provided to simplify volatile PPI register hinting for the regmap. The regmap_irq API is leveraged by the 104-idi-48 and 104-dio-48e modules to support their IRQ functionality. Do their respective regmap configurations need use_hwlock set to true in this case, or is adequate locking already handled by the regmap_irq API? William Breathitt Gray (9): gpio: regmap: Always set gpio_chip get_direction regmap-irq: Add handle_mask_sync() callback gpio: 104-dio-48e: Migrate to the regmap-irq API gpio: 104-idi-48: Migrate to the regmap-irq API gpio: 104-idi-48: Migrate to gpio-regmap API gpio: i8255: Migrate to gpio-regmap API gpio: 104-dio-48e: Migrate to regmap API gpio: gpio-mm: Migrate to regmap API gpio: i8255: Remove unused legacy interface drivers/base/regmap/regmap-irq.c | 44 +++- drivers/gpio/Kconfig | 5 +- drivers/gpio/gpio-104-dio-48e.c | 391 ++++++++++--------------------- drivers/gpio/gpio-104-idi-48.c | 336 +++++++++----------------- drivers/gpio/gpio-gpio-mm.c | 154 +++--------- drivers/gpio/gpio-i8255.c | 320 +++++++------------------ drivers/gpio/gpio-i8255.h | 54 ++--- drivers/gpio/gpio-regmap.c | 7 +- include/linux/regmap.h | 5 + 9 files changed, 416 insertions(+), 900 deletions(-) base-commit: 3b7c7478eda00945987d45f902bc3942c89243d3