From nobody Sat Apr 18 11:01:09 2026 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 C5564CCA47B for ; Thu, 14 Jul 2022 16:14:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238889AbiGNQOP (ORCPT ); Thu, 14 Jul 2022 12:14:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231297AbiGNQOL (ORCPT ); Thu, 14 Jul 2022 12:14:11 -0400 Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A8B511C3E for ; Thu, 14 Jul 2022 09:14:10 -0700 (PDT) Received: by mail-qk1-x734.google.com with SMTP id o21so1542775qkm.10 for ; Thu, 14 Jul 2022 09:14:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mFSTD6wveJdVFdIc7MwStIh/vF25P1SbCtUGXzm3kOk=; b=eovREipWybbyqgn//4S89yttA+tchfUg0XDFBTsby/VK7kOIUtOUBc36fOSPTR4jUz L8wMuiyfYa5iBvtJawkZicZQV0Pii7EocQqQ1VVChxJDO3rGF2QgL+75BDs+T1dLS9BS TghO9YngU50ccyw4XxKaCrMr03ec5Mhm4kjHu3X4LhJu7iQKgGnHOfu0dtyDyTkvMZAP Kc8ex4aIbW3Ncnwt2dKFBMhxBshGDWb9cKtfm975qSGLtl689kAEl1gFa+pfpj2Yaqk9 u9Xuc/c1SlrFIIWfNO/qSwLEtOTanSQfGS2n3PkAxvtRcUwdwSPs5L3E5deDvzq30dNC 4mOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mFSTD6wveJdVFdIc7MwStIh/vF25P1SbCtUGXzm3kOk=; b=vXCyLpRyIKL2WBjJS9oFCwvKF0TKciYw7nXYXn0ee903OjlGovjDWzlJk5BoVWLYmn 2DGKlGCbQw661xTgqSj9cPYRbKL3Pz9bsGxLqDzQj+Rbv3mBJ8Okl8D0bHWO8cQynG7H pxj116OwS0cgLxGkXRAxkbpzOyJeQmxWHEZB7iWTMg7Fvg26QR2edcYa/Gi4RE8Gv2AR Ts/ZufO8u1qfGS6upvbbMKOetNcVqYFCvEwLnTdjYKgVfaIJ+B4DN3hisBSJifhNC7Vb 5i1MqQ2URPE1olncnAhpODmfFWUnjzOzq8XG0Zt8eitPgQbyM/XW/k6e4dKr3FgE/CiN xzBA== X-Gm-Message-State: AJIora9DdrXQiTrzMnYqd+nf9sRQ1GuAGshQTsi88zgVhJ+gx2kksxwh kLn8+8Q2ff2MK1du4g6ImoT3otRJsMKLdQ== X-Google-Smtp-Source: AGRyM1uFYl2o/SW9M8GpKV+ZlQ9Z9hNenvYJM6g2a536RAB6kYThWfXtyl/0/GSTM2yijLoQ2LI05A== X-Received: by 2002:a05:620a:b4b:b0:6b5:cc47:a85e with SMTP id x11-20020a05620a0b4b00b006b5cc47a85emr133409qkg.204.1657815249240; Thu, 14 Jul 2022 09:14:09 -0700 (PDT) Received: from fedora.attlocal.net (69-109-179-158.lightspeed.dybhfl.sbcglobal.net. [69.109.179.158]) by smtp.gmail.com with ESMTPSA id cp4-20020a05622a420400b0031eb393aa45sm1690067qtb.40.2022.07.14.09.14.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jul 2022 09:14:08 -0700 (PDT) From: William Breathitt Gray To: gregkh@linuxfoundation.org Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, William Breathitt Gray Subject: [PATCH 1/4] MAINTAINERS: Update info for William Breathitt Gray Date: Thu, 14 Jul 2022 12:07:12 -0400 Message-Id: <694c2da1a01d1a3065239bf2c060018cb3308c34.1657813472.git.william.gray@linaro.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" A new job position bestowed a new email address and Counter subsystem git tree for me. Signed-off-by: William Breathitt Gray --- MAINTAINERS | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index a6d3bd9d2a8d..bb95b27f418d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -280,38 +280,38 @@ S: Maintained F: drivers/hwmon/abituguru3.c =20 ACCES 104-DIO-48E GPIO DRIVER -M: William Breathitt Gray +M: William Breathitt Gray L: linux-gpio@vger.kernel.org S: Maintained F: drivers/gpio/gpio-104-dio-48e.c =20 ACCES 104-IDI-48 GPIO DRIVER -M: "William Breathitt Gray" +M: William Breathitt Gray L: linux-gpio@vger.kernel.org S: Maintained F: drivers/gpio/gpio-104-idi-48.c =20 ACCES 104-IDIO-16 GPIO DRIVER -M: "William Breathitt Gray" +M: William Breathitt Gray L: linux-gpio@vger.kernel.org S: Maintained F: drivers/gpio/gpio-104-idio-16.c =20 ACCES 104-QUAD-8 DRIVER -M: William Breathitt Gray +M: William Breathitt Gray M: Syed Nayyar Waris L: linux-iio@vger.kernel.org S: Maintained F: drivers/counter/104-quad-8.c =20 ACCES PCI-IDIO-16 GPIO DRIVER -M: William Breathitt Gray +M: William Breathitt Gray L: linux-gpio@vger.kernel.org S: Maintained F: drivers/gpio/gpio-pci-idio-16.c =20 ACCES PCIe-IDIO-24 GPIO DRIVER -M: William Breathitt Gray +M: William Breathitt Gray L: linux-gpio@vger.kernel.org S: Maintained F: drivers/gpio/gpio-pcie-idio-24.c @@ -1354,7 +1354,7 @@ S: Maintained F: sound/aoa/ =20 APEX EMBEDDED SYSTEMS STX104 IIO DRIVER -M: William Breathitt Gray +M: William Breathitt Gray L: linux-iio@vger.kernel.org S: Maintained F: drivers/iio/adc/stx104.c @@ -5107,10 +5107,10 @@ F: Documentation/hwmon/corsair-psu.rst F: drivers/hwmon/corsair-psu.c =20 COUNTER SUBSYSTEM -M: William Breathitt Gray +M: William Breathitt Gray L: linux-iio@vger.kernel.org S: Maintained -T: git git@gitlab.com:vilhelmgray/counter.git +T: git https://git.linaro.org/people/william.gray/counter.git F: Documentation/ABI/testing/sysfs-bus-counter F: Documentation/driver-api/generic-counter.rst F: drivers/counter/ @@ -5869,7 +5869,7 @@ F: include/sound/da[79]*.h F: sound/soc/codecs/da[79]*.[ch] =20 DIAMOND SYSTEMS GPIO-MM GPIO DRIVER -M: William Breathitt Gray +M: William Breathitt Gray L: linux-gpio@vger.kernel.org S: Maintained F: drivers/gpio/gpio-gpio-mm.c @@ -10441,7 +10441,7 @@ F: Documentation/devicetree/bindings/interrupt-cont= roller/ F: drivers/irqchip/ =20 ISA -M: William Breathitt Gray +M: William Breathitt Gray S: Maintained F: Documentation/driver-api/isa.rst F: drivers/base/isa.c @@ -12194,7 +12194,7 @@ F: drivers/net/ieee802154/mcr20a.c F: drivers/net/ieee802154/mcr20a.h =20 MEASUREMENT COMPUTING CIO-DAC IIO DRIVER -M: William Breathitt Gray +M: William Breathitt Gray L: linux-iio@vger.kernel.org S: Maintained F: drivers/iio/dac/cio-dac.c @@ -21460,13 +21460,13 @@ S: Maintained F: drivers/media/rc/winbond-cir.c =20 WINSYSTEMS EBC-C384 WATCHDOG DRIVER -M: William Breathitt Gray +M: William Breathitt Gray L: linux-watchdog@vger.kernel.org S: Maintained F: drivers/watchdog/ebc-c384_wdt.c =20 WINSYSTEMS WS16C48 GPIO DRIVER -M: William Breathitt Gray +M: William Breathitt Gray L: linux-gpio@vger.kernel.org S: Maintained F: drivers/gpio/gpio-ws16c48.c --=20 2.36.1 From nobody Sat Apr 18 11:01:09 2026 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 26A59C433EF for ; Thu, 14 Jul 2022 16:14:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232370AbiGNQOS (ORCPT ); Thu, 14 Jul 2022 12:14:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238132AbiGNQON (ORCPT ); Thu, 14 Jul 2022 12:14:13 -0400 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BBF45C367 for ; Thu, 14 Jul 2022 09:14:11 -0700 (PDT) Received: by mail-qk1-x731.google.com with SMTP id n2so174615qkk.8 for ; Thu, 14 Jul 2022 09:14:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KQPe1ihuWgQ1cKWvSKyThfLnBcOK7MIWA02HL/UQUBU=; b=KC7dzIEqDIfWz2nVFucT+47MO3NaIvsPujctXxWj7AxpLYi+BovUMr2zx1MxQNCgOM 3R/Nxt9lz9Ppxm3khsWUbNBoGwJm30zVjQNDLQ9D32nkf1IK0bgsYsv0cvH+nkXIWl9M a1ALcc7ju2vUvOrW4i4HmY41r1SS8ryYBlDEoHjyWZ6dCg0omehWF08Q4dE19Us9R1DJ 56vDiezPqAqRfXVP5xmSJ02BRMq/v78UU4OxJQjoerrc8p3IosRfRyyYg0ufbQWYkKaO pDidioyBEmVRJQEIzvKBlEzpw/bYgWGmIWissz8y7trJfjI+WPi19yAbGNIjxCWp3nh8 8p4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KQPe1ihuWgQ1cKWvSKyThfLnBcOK7MIWA02HL/UQUBU=; b=r5ghd9Rr4f78htt7fyyDUIicJst1jjZcxpIPfuR9NFc5PDtDUezcGA2hFA7+28nx3d Hk/soP2u26o7hCuvyyEBF4IqTU+Xpnpalq+f+JmNyb2ordDCr3+77VVMxxkiaVv+Ykc7 oAK7nRbYIT53qY58hEBH3SH5i0iaZiAkxvwvJw5uiw10/Pdn87FuMKPyDHekHutDcCst 1+5yju6Y1sYJR8rm4kjBP7qsLVBjAZb2Byae1CkOfjZZOJkCEmzJSRyybTrl/MxhOWjL jbCCH4hA9MIwgyQhJRktN3gkCQCI1b82FZa2/44/gPblIDM5E8b4aCqde/ZC7010+6ki PzzA== X-Gm-Message-State: AJIora/8giB32DeJQaaM8I0/9cllRbZcsBih3DvDByvygXH0/LbdSqz5 phv0d282U1GaD2tn8E89Co7u7A== X-Google-Smtp-Source: AGRyM1sKoEz/sLANU7LT3xkUC43Zvd8IKqM1pddzX1bO/ftXM1SYkTZFjxLR2Ht53PBMrzJtEDvrBA== X-Received: by 2002:a05:620a:440e:b0:6b2:82cf:d7f9 with SMTP id v14-20020a05620a440e00b006b282cfd7f9mr6363748qkp.761.1657815250347; Thu, 14 Jul 2022 09:14:10 -0700 (PDT) Received: from fedora.attlocal.net (69-109-179-158.lightspeed.dybhfl.sbcglobal.net. [69.109.179.158]) by smtp.gmail.com with ESMTPSA id cp4-20020a05622a420400b0031eb393aa45sm1690067qtb.40.2022.07.14.09.14.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jul 2022 09:14:10 -0700 (PDT) From: William Breathitt Gray To: gregkh@linuxfoundation.org Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, William Breathitt Gray , David Laight , Syed Nayyar Waris , Linus Walleij Subject: [PATCH 2/4] counter: 104-quad-8: Utilize iomap interface Date: Thu, 14 Jul 2022 12:07:13 -0400 Message-Id: X-Mailer: git-send-email 2.36.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This driver doesn't need to access I/O ports directly via inb()/outb() and friends. This patch abstracts such access by calling ioport_map() to enable the use of more typical ioread8()/iowrite8() I/O memory accessor calls. Suggested-by: David Laight Cc: Syed Nayyar Waris Reviewed-by: Linus Walleij Link: https://lore.kernel.org/r/861c003318dce3d2bef4061711643bb04f5ec14f.16= 52201921.git.william.gray@linaro.org Signed-off-by: William Breathitt Gray --- drivers/counter/104-quad-8.c | 169 ++++++++++++++++++----------------- 1 file changed, 89 insertions(+), 80 deletions(-) diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c index a17e51d65aca..43dde9abfdcf 100644 --- a/drivers/counter/104-quad-8.c +++ b/drivers/counter/104-quad-8.c @@ -63,7 +63,7 @@ struct quad8 { unsigned int synchronous_mode[QUAD8_NUM_COUNTERS]; unsigned int index_polarity[QUAD8_NUM_COUNTERS]; unsigned int cable_fault_enable; - unsigned int base; + void __iomem *base; }; =20 #define QUAD8_REG_INTERRUPT_STATUS 0x10 @@ -118,8 +118,8 @@ static int quad8_signal_read(struct counter_device *cou= nter, if (signal->id < 16) return -EINVAL; =20 - state =3D inb(priv->base + QUAD8_REG_INDEX_INPUT_LEVELS) - & BIT(signal->id - 16); + state =3D ioread8(priv->base + QUAD8_REG_INDEX_INPUT_LEVELS) & + BIT(signal->id - 16); =20 *level =3D (state) ? COUNTER_SIGNAL_LEVEL_HIGH : COUNTER_SIGNAL_LEVEL_LOW; =20 @@ -130,14 +130,14 @@ static int quad8_count_read(struct counter_device *co= unter, struct counter_count *count, u64 *val) { struct quad8 *const priv =3D counter_priv(counter); - const int base_offset =3D priv->base + 2 * count->id; + void __iomem *const base_offset =3D priv->base + 2 * count->id; unsigned int flags; unsigned int borrow; unsigned int carry; unsigned long irqflags; int i; =20 - flags =3D inb(base_offset + 1); + flags =3D ioread8(base_offset + 1); borrow =3D flags & QUAD8_FLAG_BT; carry =3D !!(flags & QUAD8_FLAG_CT); =20 @@ -147,11 +147,11 @@ static int quad8_count_read(struct counter_device *co= unter, spin_lock_irqsave(&priv->lock, irqflags); =20 /* Reset Byte Pointer; transfer Counter to Output Latch */ - outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP | QUAD8_RLD_CNTR_OUT, - base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP | QUAD8_RLD_CNTR_OUT, + base_offset + 1); =20 for (i =3D 0; i < 3; i++) - *val |=3D (unsigned long)inb(base_offset) << (8 * i); + *val |=3D (unsigned long)ioread8(base_offset) << (8 * i); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -162,7 +162,7 @@ static int quad8_count_write(struct counter_device *cou= nter, struct counter_count *count, u64 val) { struct quad8 *const priv =3D counter_priv(counter); - const int base_offset =3D priv->base + 2 * count->id; + void __iomem *const base_offset =3D priv->base + 2 * count->id; unsigned long irqflags; int i; =20 @@ -173,27 +173,27 @@ static int quad8_count_write(struct counter_device *c= ounter, spin_lock_irqsave(&priv->lock, irqflags); =20 /* Reset Byte Pointer */ - outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); =20 /* Counter can only be set via Preset Register */ for (i =3D 0; i < 3; i++) - outb(val >> (8 * i), base_offset); + iowrite8(val >> (8 * i), base_offset); =20 /* Transfer Preset Register to Counter */ - outb(QUAD8_CTR_RLD | QUAD8_RLD_PRESET_CNTR, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_PRESET_CNTR, base_offset + 1); =20 /* Reset Byte Pointer */ - outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); =20 /* Set Preset Register back to original value */ val =3D priv->preset[count->id]; for (i =3D 0; i < 3; i++) - outb(val >> (8 * i), base_offset); + iowrite8(val >> (8 * i), base_offset); =20 /* Reset Borrow, Carry, Compare, and Sign flags */ - outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_FLAGS, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_FLAGS, base_offset + 1); /* Reset Error flag */ - outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_E, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_E, base_offset + 1); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -246,7 +246,7 @@ static int quad8_function_write(struct counter_device *= counter, unsigned int *const quadrature_mode =3D priv->quadrature_mode + id; unsigned int *const scale =3D priv->quadrature_scale + id; unsigned int *const synchronous_mode =3D priv->synchronous_mode + id; - const int base_offset =3D priv->base + 2 * id + 1; + void __iomem *const base_offset =3D priv->base + 2 * id + 1; unsigned long irqflags; unsigned int mode_cfg; unsigned int idr_cfg; @@ -266,7 +266,7 @@ static int quad8_function_write(struct counter_device *= counter, if (*synchronous_mode) { *synchronous_mode =3D 0; /* Disable synchronous function mode */ - outb(QUAD8_CTR_IDR | idr_cfg, base_offset); + iowrite8(QUAD8_CTR_IDR | idr_cfg, base_offset); } } else { *quadrature_mode =3D 1; @@ -292,7 +292,7 @@ static int quad8_function_write(struct counter_device *= counter, } =20 /* Load mode configuration to Counter Mode Register */ - outb(QUAD8_CTR_CMR | mode_cfg, base_offset); + iowrite8(QUAD8_CTR_CMR | mode_cfg, base_offset); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -305,10 +305,10 @@ static int quad8_direction_read(struct counter_device= *counter, { const struct quad8 *const priv =3D counter_priv(counter); unsigned int ud_flag; - const unsigned int flag_addr =3D priv->base + 2 * count->id + 1; + void __iomem *const flag_addr =3D priv->base + 2 * count->id + 1; =20 /* U/D flag: nonzero =3D up, zero =3D down */ - ud_flag =3D inb(flag_addr) & QUAD8_FLAG_UD; + ud_flag =3D ioread8(flag_addr) & QUAD8_FLAG_UD; =20 *direction =3D (ud_flag) ? COUNTER_COUNT_DIRECTION_FORWARD : COUNTER_COUNT_DIRECTION_BACKWARD; @@ -402,7 +402,7 @@ static int quad8_events_configure(struct counter_device= *counter) struct counter_event_node *event_node; unsigned int next_irq_trigger; unsigned long ior_cfg; - unsigned long base_offset; + void __iomem *base_offset; =20 spin_lock_irqsave(&priv->lock, irqflags); =20 @@ -438,13 +438,13 @@ static int quad8_events_configure(struct counter_devi= ce *counter) priv->preset_enable[event_node->channel] << 1 | priv->irq_trigger[event_node->channel] << 3; base_offset =3D priv->base + 2 * event_node->channel + 1; - outb(QUAD8_CTR_IOR | ior_cfg, base_offset); + iowrite8(QUAD8_CTR_IOR | ior_cfg, base_offset); =20 /* Enable IRQ line */ irq_enabled |=3D BIT(event_node->channel); } =20 - outb(irq_enabled, priv->base + QUAD8_REG_INDEX_INTERRUPT); + iowrite8(irq_enabled, priv->base + QUAD8_REG_INDEX_INTERRUPT); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -508,7 +508,7 @@ static int quad8_index_polarity_set(struct counter_devi= ce *counter, { struct quad8 *const priv =3D counter_priv(counter); const size_t channel_id =3D signal->id - 16; - const int base_offset =3D priv->base + 2 * channel_id + 1; + void __iomem *const base_offset =3D priv->base + 2 * channel_id + 1; unsigned long irqflags; unsigned int idr_cfg =3D index_polarity << 1; =20 @@ -519,7 +519,7 @@ static int quad8_index_polarity_set(struct counter_devi= ce *counter, priv->index_polarity[channel_id] =3D index_polarity; =20 /* Load Index Control configuration to Index Control Register */ - outb(QUAD8_CTR_IDR | idr_cfg, base_offset); + iowrite8(QUAD8_CTR_IDR | idr_cfg, base_offset); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -549,7 +549,7 @@ static int quad8_synchronous_mode_set(struct counter_de= vice *counter, { struct quad8 *const priv =3D counter_priv(counter); const size_t channel_id =3D signal->id - 16; - const int base_offset =3D priv->base + 2 * channel_id + 1; + void __iomem *const base_offset =3D priv->base + 2 * channel_id + 1; unsigned long irqflags; unsigned int idr_cfg =3D synchronous_mode; =20 @@ -566,7 +566,7 @@ static int quad8_synchronous_mode_set(struct counter_de= vice *counter, priv->synchronous_mode[channel_id] =3D synchronous_mode; =20 /* Load Index Control configuration to Index Control Register */ - outb(QUAD8_CTR_IDR | idr_cfg, base_offset); + iowrite8(QUAD8_CTR_IDR | idr_cfg, base_offset); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -614,7 +614,7 @@ static int quad8_count_mode_write(struct counter_device= *counter, struct quad8 *const priv =3D counter_priv(counter); unsigned int count_mode; unsigned int mode_cfg; - const int base_offset =3D priv->base + 2 * count->id + 1; + void __iomem *const base_offset =3D priv->base + 2 * count->id + 1; unsigned long irqflags; =20 /* Map Generic Counter count mode to 104-QUAD-8 count mode */ @@ -648,7 +648,7 @@ static int quad8_count_mode_write(struct counter_device= *counter, mode_cfg |=3D (priv->quadrature_scale[count->id] + 1) << 3; =20 /* Load mode configuration to Counter Mode Register */ - outb(QUAD8_CTR_CMR | mode_cfg, base_offset); + iowrite8(QUAD8_CTR_CMR | mode_cfg, base_offset); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -669,7 +669,7 @@ static int quad8_count_enable_write(struct counter_devi= ce *counter, struct counter_count *count, u8 enable) { struct quad8 *const priv =3D counter_priv(counter); - const int base_offset =3D priv->base + 2 * count->id; + void __iomem *const base_offset =3D priv->base + 2 * count->id; unsigned long irqflags; unsigned int ior_cfg; =20 @@ -681,7 +681,7 @@ static int quad8_count_enable_write(struct counter_devi= ce *counter, priv->irq_trigger[count->id] << 3; =20 /* Load I/O control configuration */ - outb(QUAD8_CTR_IOR | ior_cfg, base_offset + 1); + iowrite8(QUAD8_CTR_IOR | ior_cfg, base_offset + 1); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -697,9 +697,9 @@ static int quad8_error_noise_get(struct counter_device = *counter, struct counter_count *count, u32 *noise_error) { const struct quad8 *const priv =3D counter_priv(counter); - const int base_offset =3D priv->base + 2 * count->id + 1; + void __iomem *const base_offset =3D priv->base + 2 * count->id + 1; =20 - *noise_error =3D !!(inb(base_offset) & QUAD8_FLAG_E); + *noise_error =3D !!(ioread8(base_offset) & QUAD8_FLAG_E); =20 return 0; } @@ -717,17 +717,17 @@ static int quad8_count_preset_read(struct counter_dev= ice *counter, static void quad8_preset_register_set(struct quad8 *const priv, const int = id, const unsigned int preset) { - const unsigned int base_offset =3D priv->base + 2 * id; + void __iomem *const base_offset =3D priv->base + 2 * id; int i; =20 priv->preset[id] =3D preset; =20 /* Reset Byte Pointer */ - outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); =20 /* Set Preset Register */ for (i =3D 0; i < 3; i++) - outb(preset >> (8 * i), base_offset); + iowrite8(preset >> (8 * i), base_offset); } =20 static int quad8_count_preset_write(struct counter_device *counter, @@ -816,7 +816,7 @@ static int quad8_count_preset_enable_write(struct count= er_device *counter, u8 preset_enable) { struct quad8 *const priv =3D counter_priv(counter); - const int base_offset =3D priv->base + 2 * count->id + 1; + void __iomem *const base_offset =3D priv->base + 2 * count->id + 1; unsigned long irqflags; unsigned int ior_cfg; =20 @@ -831,7 +831,7 @@ static int quad8_count_preset_enable_write(struct count= er_device *counter, priv->irq_trigger[count->id] << 3; =20 /* Load I/O control configuration to Input / Output Control Register */ - outb(QUAD8_CTR_IOR | ior_cfg, base_offset); + iowrite8(QUAD8_CTR_IOR | ior_cfg, base_offset); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -858,7 +858,7 @@ static int quad8_signal_cable_fault_read(struct counter= _device *counter, } =20 /* Logic 0 =3D cable fault */ - status =3D inb(priv->base + QUAD8_DIFF_ENCODER_CABLE_STATUS); + status =3D ioread8(priv->base + QUAD8_DIFF_ENCODER_CABLE_STATUS); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -899,7 +899,8 @@ static int quad8_signal_cable_fault_enable_write(struct= counter_device *counter, /* Enable is active low in Differential Encoder Cable Status register */ cable_fault_enable =3D ~priv->cable_fault_enable; =20 - outb(cable_fault_enable, priv->base + QUAD8_DIFF_ENCODER_CABLE_STATUS); + iowrite8(cable_fault_enable, + priv->base + QUAD8_DIFF_ENCODER_CABLE_STATUS); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -923,7 +924,7 @@ static int quad8_signal_fck_prescaler_write(struct coun= ter_device *counter, { struct quad8 *const priv =3D counter_priv(counter); const size_t channel_id =3D signal->id / 2; - const int base_offset =3D priv->base + 2 * channel_id; + void __iomem *const base_offset =3D priv->base + 2 * channel_id; unsigned long irqflags; =20 spin_lock_irqsave(&priv->lock, irqflags); @@ -931,12 +932,12 @@ static int quad8_signal_fck_prescaler_write(struct co= unter_device *counter, priv->fck_prescaler[channel_id] =3D prescaler; =20 /* Reset Byte Pointer */ - outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); =20 /* Set filter clock factor */ - outb(prescaler, base_offset); - outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP | QUAD8_RLD_PRESET_PSC, - base_offset + 1); + iowrite8(prescaler, base_offset); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP | QUAD8_RLD_PRESET_PSC, + base_offset + 1); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -1084,12 +1085,12 @@ static irqreturn_t quad8_irq_handler(int irq, void = *private) { struct counter_device *counter =3D private; struct quad8 *const priv =3D counter_priv(counter); - const unsigned long base =3D priv->base; + void __iomem *const base =3D priv->base; unsigned long irq_status; unsigned long channel; u8 event; =20 - irq_status =3D inb(base + QUAD8_REG_INTERRUPT_STATUS); + irq_status =3D ioread8(base + QUAD8_REG_INTERRUPT_STATUS); if (!irq_status) return IRQ_NONE; =20 @@ -1118,17 +1119,43 @@ static irqreturn_t quad8_irq_handler(int irq, void = *private) } =20 /* Clear pending interrupts on device */ - outb(QUAD8_CHAN_OP_ENABLE_INTERRUPT_FUNC, base + QUAD8_REG_CHAN_OP); + iowrite8(QUAD8_CHAN_OP_ENABLE_INTERRUPT_FUNC, base + QUAD8_REG_CHAN_OP); =20 return IRQ_HANDLED; } =20 +static void quad8_init_counter(void __iomem *const base_offset) +{ + unsigned long i; + + /* Reset Byte Pointer */ + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); + /* Reset filter clock factor */ + iowrite8(0, base_offset); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP | QUAD8_RLD_PRESET_PSC, + base_offset + 1); + /* Reset Byte Pointer */ + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); + /* Reset Preset Register */ + for (i =3D 0; i < 3; i++) + iowrite8(0x00, base_offset); + /* Reset Borrow, Carry, Compare, and Sign flags */ + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_FLAGS, base_offset + 1); + /* Reset Error flag */ + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_E, base_offset + 1); + /* Binary encoding; Normal count; non-quadrature mode */ + iowrite8(QUAD8_CTR_CMR, base_offset + 1); + /* Disable A and B inputs; preset on index; FLG1 as Carry */ + iowrite8(QUAD8_CTR_IOR, base_offset + 1); + /* Disable index function; negative index polarity */ + iowrite8(QUAD8_CTR_IDR, base_offset + 1); +} + static int quad8_probe(struct device *dev, unsigned int id) { struct counter_device *counter; struct quad8 *priv; - int i, j; - unsigned int base_offset; + unsigned long i; int err; =20 if (!devm_request_region(dev, base[id], QUAD8_EXTENT, dev_name(dev))) { @@ -1142,6 +1169,10 @@ static int quad8_probe(struct device *dev, unsigned = int id) return -ENOMEM; priv =3D counter_priv(counter); =20 + priv->base =3D devm_ioport_map(dev, base[id], QUAD8_EXTENT); + if (!priv->base) + return -ENOMEM; + /* Initialize Counter device and driver data */ counter->name =3D dev_name(dev); counter->parent =3D dev; @@ -1150,43 +1181,21 @@ static int quad8_probe(struct device *dev, unsigned= int id) counter->num_counts =3D ARRAY_SIZE(quad8_counts); counter->signals =3D quad8_signals; counter->num_signals =3D ARRAY_SIZE(quad8_signals); - priv->base =3D base[id]; =20 spin_lock_init(&priv->lock); =20 /* Reset Index/Interrupt Register */ - outb(0x00, base[id] + QUAD8_REG_INDEX_INTERRUPT); + iowrite8(0x00, priv->base + QUAD8_REG_INDEX_INTERRUPT); /* Reset all counters and disable interrupt function */ - outb(QUAD8_CHAN_OP_RESET_COUNTERS, base[id] + QUAD8_REG_CHAN_OP); + iowrite8(QUAD8_CHAN_OP_RESET_COUNTERS, priv->base + QUAD8_REG_CHAN_OP); /* Set initial configuration for all counters */ - for (i =3D 0; i < QUAD8_NUM_COUNTERS; i++) { - base_offset =3D base[id] + 2 * i; - /* Reset Byte Pointer */ - outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); - /* Reset filter clock factor */ - outb(0, base_offset); - outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP | QUAD8_RLD_PRESET_PSC, - base_offset + 1); - /* Reset Byte Pointer */ - outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); - /* Reset Preset Register */ - for (j =3D 0; j < 3; j++) - outb(0x00, base_offset); - /* Reset Borrow, Carry, Compare, and Sign flags */ - outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_FLAGS, base_offset + 1); - /* Reset Error flag */ - outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_E, base_offset + 1); - /* Binary encoding; Normal count; non-quadrature mode */ - outb(QUAD8_CTR_CMR, base_offset + 1); - /* Disable A and B inputs; preset on index; FLG1 as Carry */ - outb(QUAD8_CTR_IOR, base_offset + 1); - /* Disable index function; negative index polarity */ - outb(QUAD8_CTR_IDR, base_offset + 1); - } + for (i =3D 0; i < QUAD8_NUM_COUNTERS; i++) + quad8_init_counter(priv->base + 2 * i); /* Disable Differential Encoder Cable Status for all channels */ - outb(0xFF, base[id] + QUAD8_DIFF_ENCODER_CABLE_STATUS); + iowrite8(0xFF, priv->base + QUAD8_DIFF_ENCODER_CABLE_STATUS); /* Enable all counters and enable interrupt function */ - outb(QUAD8_CHAN_OP_ENABLE_INTERRUPT_FUNC, base[id] + QUAD8_REG_CHAN_OP); + iowrite8(QUAD8_CHAN_OP_ENABLE_INTERRUPT_FUNC, + priv->base + QUAD8_REG_CHAN_OP); =20 err =3D devm_request_irq(&counter->dev, irq[id], quad8_irq_handler, IRQF_SHARED, counter->name, counter); --=20 2.36.1 From nobody Sat Apr 18 11:01:09 2026 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 0FF3CC433EF for ; Thu, 14 Jul 2022 16:14:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239060AbiGNQO1 (ORCPT ); Thu, 14 Jul 2022 12:14:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238969AbiGNQOQ (ORCPT ); Thu, 14 Jul 2022 12:14:16 -0400 Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08820606B7 for ; Thu, 14 Jul 2022 09:14:14 -0700 (PDT) Received: by mail-qt1-x82c.google.com with SMTP id ck6so1788263qtb.7 for ; Thu, 14 Jul 2022 09:14:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=K69smE047kc9hjOIVvY0GsHKu9IjTd/ToaQTmAGOUqI=; b=YPlpm1IirtxC6oJE3dvHkp9kCbClQ9U9WA/CJ5YNnyxJjHPKOKvmyVng6OHQHYsfOa smvUsa2zg4MDj4hyqZy1NTjkXjLG5LJJiMWHHaJCiako6xkek4pMrXNIYmFeOEE68YPJ FQJl408sOkmkU2hLhswzN8/CxR2jPxAOlO4g96/ADlqVvLOUBCefKWaIR2scqIM3pLR4 XNp/lmsXZ04cOGkBqrACl3LBiJt/q0SIiM0zxelW41CgvRS4tvfNGHgfZpKYM03A/FY8 Rh+stJF65txYDRBMysG9cyOkqc79U3IE1STuLiM/PB/ygPPXVNXQEUbjf9MjwbCLHhkM r/1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=K69smE047kc9hjOIVvY0GsHKu9IjTd/ToaQTmAGOUqI=; b=MytMuLxfBl0ogRLRCFlkbZ+uwQeyxcSKCWiS/mcR5dxL4eZjxA3pncyITisY4MmgeZ KAQyqVD6SD+6ZNmF2QCfJtrruQ7XZgF1ay6LR+vOdLZXDH0k4801jXMPVOoJAgxyUmS3 gcOylT//bwGYVQ4Q53uFIu/QJVjclhUfMZCX7dIC1p5TZxI/8nPcYbN3QBI6fFtJ8hqQ RDRpRhK4jo2NJYNXbXg/Xt+nfHms5HM12anj8c2m/7LUIJ14vh1LKT24fUjOoz3OYlIT HYHdi6K8HXSDk48FGz2KPhWScLmoCLEbN8OEOy5X9znwNRtk6O2z9DPOTou5YKiAOcfK UyBQ== X-Gm-Message-State: AJIora9oJdVaETnFelIq/6pN6nwrQUTS41SERThzn7ZpC/E1zpdY3fkZ lKLJaYYZ06AvhYxT6yJU/eJpPg== X-Google-Smtp-Source: AGRyM1t6QjI4qV3xKhAsouoq3n3ntOgzODNopZxVyQzaBeyQoRIDs/9Rmjj4vj5MmEXy5Qzgr+cGlQ== X-Received: by 2002:a05:622a:494:b0:31e:d6f2:5502 with SMTP id p20-20020a05622a049400b0031ed6f25502mr1332602qtx.129.1657815253001; Thu, 14 Jul 2022 09:14:13 -0700 (PDT) Received: from fedora.attlocal.net (69-109-179-158.lightspeed.dybhfl.sbcglobal.net. [69.109.179.158]) by smtp.gmail.com with ESMTPSA id cp4-20020a05622a420400b0031eb393aa45sm1690067qtb.40.2022.07.14.09.14.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jul 2022 09:14:12 -0700 (PDT) From: William Breathitt Gray To: gregkh@linuxfoundation.org Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, William Breathitt Gray , Jonathan Cameron , Fred Eckert , Syed Nayyar Waris Subject: [PATCH 3/4] counter: 104-quad-8: Implement and utilize register structures Date: Thu, 14 Jul 2022 12:07:14 -0400 Message-Id: <285fdc7c03892251f50bdbf2c28c19998243a6a3.1657813472.git.william.gray@linaro.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Reduce magic numbers and improve code readability by implementing and utilizing named register data structures. Reviewed-by: Jonathan Cameron Tested-by: Fred Eckert Cc: Syed Nayyar Waris Link: https://lore.kernel.org/r/20220707171709.36010-1-william.gray@linaro.= org/ Signed-off-by: William Breathitt Gray --- drivers/counter/104-quad-8.c | 166 ++++++++++++++++++++--------------- 1 file changed, 93 insertions(+), 73 deletions(-) diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c index 43dde9abfdcf..62c2b7ac4339 100644 --- a/drivers/counter/104-quad-8.c +++ b/drivers/counter/104-quad-8.c @@ -33,6 +33,36 @@ MODULE_PARM_DESC(irq, "ACCES 104-QUAD-8 interrupt line n= umbers"); =20 #define QUAD8_NUM_COUNTERS 8 =20 +/** + * struct channel_reg - channel register structure + * @data: Count data + * @control: Channel flags and control + */ +struct channel_reg { + u8 data; + u8 control; +}; + +/** + * struct quad8_reg - device register structure + * @channel: quadrature counter data and control + * @interrupt_status: channel interrupt status + * @channel_oper: enable/reset counters and interrupt functions + * @index_interrupt: enable channel interrupts + * @reserved: reserved for Factory Use + * @index_input_levels: index signal logical input level + * @cable_status: differential encoder cable status + */ +struct quad8_reg { + struct channel_reg channel[QUAD8_NUM_COUNTERS]; + u8 interrupt_status; + u8 channel_oper; + u8 index_interrupt; + u8 reserved[3]; + u8 index_input_levels; + u8 cable_status; +}; + /** * struct quad8 - device private data structure * @lock: lock to prevent clobbering device states during R/W ops @@ -48,7 +78,7 @@ MODULE_PARM_DESC(irq, "ACCES 104-QUAD-8 interrupt line nu= mbers"); * @synchronous_mode: array of index function synchronous mode configurati= ons * @index_polarity: array of index function polarity configurations * @cable_fault_enable: differential encoder cable status enable configura= tions - * @base: base port address of the device + * @reg: I/O address offset for the device registers */ struct quad8 { spinlock_t lock; @@ -63,14 +93,9 @@ struct quad8 { unsigned int synchronous_mode[QUAD8_NUM_COUNTERS]; unsigned int index_polarity[QUAD8_NUM_COUNTERS]; unsigned int cable_fault_enable; - void __iomem *base; + struct quad8_reg __iomem *reg; }; =20 -#define QUAD8_REG_INTERRUPT_STATUS 0x10 -#define QUAD8_REG_CHAN_OP 0x11 -#define QUAD8_REG_INDEX_INTERRUPT 0x12 -#define QUAD8_REG_INDEX_INPUT_LEVELS 0x16 -#define QUAD8_DIFF_ENCODER_CABLE_STATUS 0x17 /* Borrow Toggle flip-flop */ #define QUAD8_FLAG_BT BIT(0) /* Carry Toggle flip-flop */ @@ -118,8 +143,7 @@ static int quad8_signal_read(struct counter_device *cou= nter, if (signal->id < 16) return -EINVAL; =20 - state =3D ioread8(priv->base + QUAD8_REG_INDEX_INPUT_LEVELS) & - BIT(signal->id - 16); + state =3D ioread8(&priv->reg->index_input_levels) & BIT(signal->id - 16); =20 *level =3D (state) ? COUNTER_SIGNAL_LEVEL_HIGH : COUNTER_SIGNAL_LEVEL_LOW; =20 @@ -130,14 +154,14 @@ static int quad8_count_read(struct counter_device *co= unter, struct counter_count *count, u64 *val) { struct quad8 *const priv =3D counter_priv(counter); - void __iomem *const base_offset =3D priv->base + 2 * count->id; + struct channel_reg __iomem *const chan =3D priv->reg->channel + count->id; unsigned int flags; unsigned int borrow; unsigned int carry; unsigned long irqflags; int i; =20 - flags =3D ioread8(base_offset + 1); + flags =3D ioread8(&chan->control); borrow =3D flags & QUAD8_FLAG_BT; carry =3D !!(flags & QUAD8_FLAG_CT); =20 @@ -148,10 +172,10 @@ static int quad8_count_read(struct counter_device *co= unter, =20 /* Reset Byte Pointer; transfer Counter to Output Latch */ iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP | QUAD8_RLD_CNTR_OUT, - base_offset + 1); + &chan->control); =20 for (i =3D 0; i < 3; i++) - *val |=3D (unsigned long)ioread8(base_offset) << (8 * i); + *val |=3D (unsigned long)ioread8(&chan->data) << (8 * i); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -162,7 +186,7 @@ static int quad8_count_write(struct counter_device *cou= nter, struct counter_count *count, u64 val) { struct quad8 *const priv =3D counter_priv(counter); - void __iomem *const base_offset =3D priv->base + 2 * count->id; + struct channel_reg __iomem *const chan =3D priv->reg->channel + count->id; unsigned long irqflags; int i; =20 @@ -173,27 +197,27 @@ static int quad8_count_write(struct counter_device *c= ounter, spin_lock_irqsave(&priv->lock, irqflags); =20 /* Reset Byte Pointer */ - iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, &chan->control); =20 /* Counter can only be set via Preset Register */ for (i =3D 0; i < 3; i++) - iowrite8(val >> (8 * i), base_offset); + iowrite8(val >> (8 * i), &chan->data); =20 /* Transfer Preset Register to Counter */ - iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_PRESET_CNTR, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_PRESET_CNTR, &chan->control); =20 /* Reset Byte Pointer */ - iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, &chan->control); =20 /* Set Preset Register back to original value */ val =3D priv->preset[count->id]; for (i =3D 0; i < 3; i++) - iowrite8(val >> (8 * i), base_offset); + iowrite8(val >> (8 * i), &chan->data); =20 /* Reset Borrow, Carry, Compare, and Sign flags */ - iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_FLAGS, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_FLAGS, &chan->control); /* Reset Error flag */ - iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_E, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_E, &chan->control); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -246,7 +270,7 @@ static int quad8_function_write(struct counter_device *= counter, unsigned int *const quadrature_mode =3D priv->quadrature_mode + id; unsigned int *const scale =3D priv->quadrature_scale + id; unsigned int *const synchronous_mode =3D priv->synchronous_mode + id; - void __iomem *const base_offset =3D priv->base + 2 * id + 1; + u8 __iomem *const control =3D &priv->reg->channel[id].control; unsigned long irqflags; unsigned int mode_cfg; unsigned int idr_cfg; @@ -266,7 +290,7 @@ static int quad8_function_write(struct counter_device *= counter, if (*synchronous_mode) { *synchronous_mode =3D 0; /* Disable synchronous function mode */ - iowrite8(QUAD8_CTR_IDR | idr_cfg, base_offset); + iowrite8(QUAD8_CTR_IDR | idr_cfg, control); } } else { *quadrature_mode =3D 1; @@ -292,7 +316,7 @@ static int quad8_function_write(struct counter_device *= counter, } =20 /* Load mode configuration to Counter Mode Register */ - iowrite8(QUAD8_CTR_CMR | mode_cfg, base_offset); + iowrite8(QUAD8_CTR_CMR | mode_cfg, control); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -305,7 +329,7 @@ static int quad8_direction_read(struct counter_device *= counter, { const struct quad8 *const priv =3D counter_priv(counter); unsigned int ud_flag; - void __iomem *const flag_addr =3D priv->base + 2 * count->id + 1; + u8 __iomem *const flag_addr =3D &priv->reg->channel[count->id].control; =20 /* U/D flag: nonzero =3D up, zero =3D down */ ud_flag =3D ioread8(flag_addr) & QUAD8_FLAG_UD; @@ -402,7 +426,6 @@ static int quad8_events_configure(struct counter_device= *counter) struct counter_event_node *event_node; unsigned int next_irq_trigger; unsigned long ior_cfg; - void __iomem *base_offset; =20 spin_lock_irqsave(&priv->lock, irqflags); =20 @@ -437,14 +460,14 @@ static int quad8_events_configure(struct counter_devi= ce *counter) ior_cfg =3D priv->ab_enable[event_node->channel] | priv->preset_enable[event_node->channel] << 1 | priv->irq_trigger[event_node->channel] << 3; - base_offset =3D priv->base + 2 * event_node->channel + 1; - iowrite8(QUAD8_CTR_IOR | ior_cfg, base_offset); + iowrite8(QUAD8_CTR_IOR | ior_cfg, + &priv->reg->channel[event_node->channel].control); =20 /* Enable IRQ line */ irq_enabled |=3D BIT(event_node->channel); } =20 - iowrite8(irq_enabled, priv->base + QUAD8_REG_INDEX_INTERRUPT); + iowrite8(irq_enabled, &priv->reg->index_interrupt); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -508,7 +531,7 @@ static int quad8_index_polarity_set(struct counter_devi= ce *counter, { struct quad8 *const priv =3D counter_priv(counter); const size_t channel_id =3D signal->id - 16; - void __iomem *const base_offset =3D priv->base + 2 * channel_id + 1; + u8 __iomem *const control =3D &priv->reg->channel[channel_id].control; unsigned long irqflags; unsigned int idr_cfg =3D index_polarity << 1; =20 @@ -519,7 +542,7 @@ static int quad8_index_polarity_set(struct counter_devi= ce *counter, priv->index_polarity[channel_id] =3D index_polarity; =20 /* Load Index Control configuration to Index Control Register */ - iowrite8(QUAD8_CTR_IDR | idr_cfg, base_offset); + iowrite8(QUAD8_CTR_IDR | idr_cfg, control); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -549,7 +572,7 @@ static int quad8_synchronous_mode_set(struct counter_de= vice *counter, { struct quad8 *const priv =3D counter_priv(counter); const size_t channel_id =3D signal->id - 16; - void __iomem *const base_offset =3D priv->base + 2 * channel_id + 1; + u8 __iomem *const control =3D &priv->reg->channel[channel_id].control; unsigned long irqflags; unsigned int idr_cfg =3D synchronous_mode; =20 @@ -566,7 +589,7 @@ static int quad8_synchronous_mode_set(struct counter_de= vice *counter, priv->synchronous_mode[channel_id] =3D synchronous_mode; =20 /* Load Index Control configuration to Index Control Register */ - iowrite8(QUAD8_CTR_IDR | idr_cfg, base_offset); + iowrite8(QUAD8_CTR_IDR | idr_cfg, control); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -614,7 +637,7 @@ static int quad8_count_mode_write(struct counter_device= *counter, struct quad8 *const priv =3D counter_priv(counter); unsigned int count_mode; unsigned int mode_cfg; - void __iomem *const base_offset =3D priv->base + 2 * count->id + 1; + u8 __iomem *const control =3D &priv->reg->channel[count->id].control; unsigned long irqflags; =20 /* Map Generic Counter count mode to 104-QUAD-8 count mode */ @@ -648,7 +671,7 @@ static int quad8_count_mode_write(struct counter_device= *counter, mode_cfg |=3D (priv->quadrature_scale[count->id] + 1) << 3; =20 /* Load mode configuration to Counter Mode Register */ - iowrite8(QUAD8_CTR_CMR | mode_cfg, base_offset); + iowrite8(QUAD8_CTR_CMR | mode_cfg, control); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -669,7 +692,7 @@ static int quad8_count_enable_write(struct counter_devi= ce *counter, struct counter_count *count, u8 enable) { struct quad8 *const priv =3D counter_priv(counter); - void __iomem *const base_offset =3D priv->base + 2 * count->id; + u8 __iomem *const control =3D &priv->reg->channel[count->id].control; unsigned long irqflags; unsigned int ior_cfg; =20 @@ -681,7 +704,7 @@ static int quad8_count_enable_write(struct counter_devi= ce *counter, priv->irq_trigger[count->id] << 3; =20 /* Load I/O control configuration */ - iowrite8(QUAD8_CTR_IOR | ior_cfg, base_offset + 1); + iowrite8(QUAD8_CTR_IOR | ior_cfg, control); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -697,9 +720,9 @@ static int quad8_error_noise_get(struct counter_device = *counter, struct counter_count *count, u32 *noise_error) { const struct quad8 *const priv =3D counter_priv(counter); - void __iomem *const base_offset =3D priv->base + 2 * count->id + 1; + u8 __iomem *const flag_addr =3D &priv->reg->channel[count->id].control; =20 - *noise_error =3D !!(ioread8(base_offset) & QUAD8_FLAG_E); + *noise_error =3D !!(ioread8(flag_addr) & QUAD8_FLAG_E); =20 return 0; } @@ -717,17 +740,17 @@ static int quad8_count_preset_read(struct counter_dev= ice *counter, static void quad8_preset_register_set(struct quad8 *const priv, const int = id, const unsigned int preset) { - void __iomem *const base_offset =3D priv->base + 2 * id; + struct channel_reg __iomem *const chan =3D priv->reg->channel + id; int i; =20 priv->preset[id] =3D preset; =20 /* Reset Byte Pointer */ - iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, &chan->control); =20 /* Set Preset Register */ for (i =3D 0; i < 3; i++) - iowrite8(preset >> (8 * i), base_offset); + iowrite8(preset >> (8 * i), &chan->data); } =20 static int quad8_count_preset_write(struct counter_device *counter, @@ -816,7 +839,7 @@ static int quad8_count_preset_enable_write(struct count= er_device *counter, u8 preset_enable) { struct quad8 *const priv =3D counter_priv(counter); - void __iomem *const base_offset =3D priv->base + 2 * count->id + 1; + u8 __iomem *const control =3D &priv->reg->channel[count->id].control; unsigned long irqflags; unsigned int ior_cfg; =20 @@ -831,7 +854,7 @@ static int quad8_count_preset_enable_write(struct count= er_device *counter, priv->irq_trigger[count->id] << 3; =20 /* Load I/O control configuration to Input / Output Control Register */ - iowrite8(QUAD8_CTR_IOR | ior_cfg, base_offset); + iowrite8(QUAD8_CTR_IOR | ior_cfg, control); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -858,7 +881,7 @@ static int quad8_signal_cable_fault_read(struct counter= _device *counter, } =20 /* Logic 0 =3D cable fault */ - status =3D ioread8(priv->base + QUAD8_DIFF_ENCODER_CABLE_STATUS); + status =3D ioread8(&priv->reg->cable_status); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -899,8 +922,7 @@ static int quad8_signal_cable_fault_enable_write(struct= counter_device *counter, /* Enable is active low in Differential Encoder Cable Status register */ cable_fault_enable =3D ~priv->cable_fault_enable; =20 - iowrite8(cable_fault_enable, - priv->base + QUAD8_DIFF_ENCODER_CABLE_STATUS); + iowrite8(cable_fault_enable, &priv->reg->cable_status); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -924,7 +946,7 @@ static int quad8_signal_fck_prescaler_write(struct coun= ter_device *counter, { struct quad8 *const priv =3D counter_priv(counter); const size_t channel_id =3D signal->id / 2; - void __iomem *const base_offset =3D priv->base + 2 * channel_id; + struct channel_reg __iomem *const chan =3D priv->reg->channel + channel_i= d; unsigned long irqflags; =20 spin_lock_irqsave(&priv->lock, irqflags); @@ -932,12 +954,12 @@ static int quad8_signal_fck_prescaler_write(struct co= unter_device *counter, priv->fck_prescaler[channel_id] =3D prescaler; =20 /* Reset Byte Pointer */ - iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, &chan->control); =20 /* Set filter clock factor */ - iowrite8(prescaler, base_offset); + iowrite8(prescaler, &chan->data); iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP | QUAD8_RLD_PRESET_PSC, - base_offset + 1); + &chan->control); =20 spin_unlock_irqrestore(&priv->lock, irqflags); =20 @@ -1085,12 +1107,11 @@ static irqreturn_t quad8_irq_handler(int irq, void = *private) { struct counter_device *counter =3D private; struct quad8 *const priv =3D counter_priv(counter); - void __iomem *const base =3D priv->base; unsigned long irq_status; unsigned long channel; u8 event; =20 - irq_status =3D ioread8(base + QUAD8_REG_INTERRUPT_STATUS); + irq_status =3D ioread8(&priv->reg->interrupt_status); if (!irq_status) return IRQ_NONE; =20 @@ -1119,36 +1140,36 @@ static irqreturn_t quad8_irq_handler(int irq, void = *private) } =20 /* Clear pending interrupts on device */ - iowrite8(QUAD8_CHAN_OP_ENABLE_INTERRUPT_FUNC, base + QUAD8_REG_CHAN_OP); + iowrite8(QUAD8_CHAN_OP_ENABLE_INTERRUPT_FUNC, &priv->reg->channel_oper); =20 return IRQ_HANDLED; } =20 -static void quad8_init_counter(void __iomem *const base_offset) +static void quad8_init_counter(struct channel_reg __iomem *const chan) { unsigned long i; =20 /* Reset Byte Pointer */ - iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, &chan->control); /* Reset filter clock factor */ - iowrite8(0, base_offset); + iowrite8(0, &chan->data); iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP | QUAD8_RLD_PRESET_PSC, - base_offset + 1); + &chan->control); /* Reset Byte Pointer */ - iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, &chan->control); /* Reset Preset Register */ for (i =3D 0; i < 3; i++) - iowrite8(0x00, base_offset); + iowrite8(0x00, &chan->data); /* Reset Borrow, Carry, Compare, and Sign flags */ - iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_FLAGS, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_FLAGS, &chan->control); /* Reset Error flag */ - iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_E, base_offset + 1); + iowrite8(QUAD8_CTR_RLD | QUAD8_RLD_RESET_E, &chan->control); /* Binary encoding; Normal count; non-quadrature mode */ - iowrite8(QUAD8_CTR_CMR, base_offset + 1); + iowrite8(QUAD8_CTR_CMR, &chan->control); /* Disable A and B inputs; preset on index; FLG1 as Carry */ - iowrite8(QUAD8_CTR_IOR, base_offset + 1); + iowrite8(QUAD8_CTR_IOR, &chan->control); /* Disable index function; negative index polarity */ - iowrite8(QUAD8_CTR_IDR, base_offset + 1); + iowrite8(QUAD8_CTR_IDR, &chan->control); } =20 static int quad8_probe(struct device *dev, unsigned int id) @@ -1169,8 +1190,8 @@ static int quad8_probe(struct device *dev, unsigned i= nt id) return -ENOMEM; priv =3D counter_priv(counter); =20 - priv->base =3D devm_ioport_map(dev, base[id], QUAD8_EXTENT); - if (!priv->base) + priv->reg =3D devm_ioport_map(dev, base[id], QUAD8_EXTENT); + if (!priv->reg) return -ENOMEM; =20 /* Initialize Counter device and driver data */ @@ -1185,17 +1206,16 @@ static int quad8_probe(struct device *dev, unsigned= int id) spin_lock_init(&priv->lock); =20 /* Reset Index/Interrupt Register */ - iowrite8(0x00, priv->base + QUAD8_REG_INDEX_INTERRUPT); + iowrite8(0x00, &priv->reg->index_interrupt); /* Reset all counters and disable interrupt function */ - iowrite8(QUAD8_CHAN_OP_RESET_COUNTERS, priv->base + QUAD8_REG_CHAN_OP); + iowrite8(QUAD8_CHAN_OP_RESET_COUNTERS, &priv->reg->channel_oper); /* Set initial configuration for all counters */ for (i =3D 0; i < QUAD8_NUM_COUNTERS; i++) - quad8_init_counter(priv->base + 2 * i); + quad8_init_counter(priv->reg->channel + i); /* Disable Differential Encoder Cable Status for all channels */ - iowrite8(0xFF, priv->base + QUAD8_DIFF_ENCODER_CABLE_STATUS); + iowrite8(0xFF, &priv->reg->cable_status); /* Enable all counters and enable interrupt function */ - iowrite8(QUAD8_CHAN_OP_ENABLE_INTERRUPT_FUNC, - priv->base + QUAD8_REG_CHAN_OP); + iowrite8(QUAD8_CHAN_OP_ENABLE_INTERRUPT_FUNC, &priv->reg->channel_oper); =20 err =3D devm_request_irq(&counter->dev, irq[id], quad8_irq_handler, IRQF_SHARED, counter->name, counter); --=20 2.36.1 From nobody Sat Apr 18 11:01:09 2026 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 6630DC43334 for ; Thu, 14 Jul 2022 16:14:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239006AbiGNQOX (ORCPT ); Thu, 14 Jul 2022 12:14:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238905AbiGNQOQ (ORCPT ); Thu, 14 Jul 2022 12:14:16 -0400 Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4B0161713 for ; Thu, 14 Jul 2022 09:14:14 -0700 (PDT) Received: by mail-qt1-x82b.google.com with SMTP id j27so1801373qtv.4 for ; Thu, 14 Jul 2022 09:14:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7Q1rOEGSDk/MdGe+KKgrYeB7dlxzQOSbkzC7u5rM1Wc=; b=Dx7H4mPpGm5SS1i66ZMaq3PN7ZeJq4VEN+s+/tKevX/QCZkEUBxCX7A7e9Ffek9zHr lNU2RDlxT4vw/jzXY4oXX8ImwzbmKyX2/NiUIuCuTqBaNPpaQXTWX/ayJ53mxhw2IZgX kdjdmNQ4gKjLu96LTpjJ0CQjYIulOoNuflLAoyMeoPGEuKKy6IEGUDUaVORLQSU6Cg8v Uhsblg/I+njVq31aFqs+a1IJ2R7rKH3sOJRpE3qrlplmgcOKAWx2zKrmhwPaSy7n8TZA P+PenRYSsDIwDuvhVZzZVoDDvwCaZnvqejcd44U5y/DGUwugHs3r8uY2FgdUiFT6zUeP WO7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7Q1rOEGSDk/MdGe+KKgrYeB7dlxzQOSbkzC7u5rM1Wc=; b=L6UjIAiBkdXAWe+bJS/JL8Rwpo12aO+X8scwi3+pXo0w3RsJDGte967l+xc46+bfkC +ZHUa1HMjdmaWQu/L2vQ7nWW74NyhAUs01AyCd4fK1Wt9rADKWetHCDnCmidMhhdzQ5O 1vGcI5W0hRitmBT3Kdh86XhtgWG1qIzGYI8Wg9ShXEtmapjlMwR20et8DGIMC0WH/A0+ ShgMRXSsbBzIs1cuAOVyudFeWKpdmaUvI6dmOETonHc6njiNaYJWOaza6SeWHe8eFZEu qdHl9CzujoNrO/gQBJReB95N2R2/K4utCsyCzDnNxesmxPBSQeTEHl8ZMtJfuOAc+jzx SKNA== X-Gm-Message-State: AJIora9O4yDP1O/3HdvSwtsl8dgJ/6h69kSbOmT2JckKx/bo4VEsDnmy bbgoMhqa2GNqNzaIuZ4XQj/3rw== X-Google-Smtp-Source: AGRyM1uTqE6ZqqqpvevdUWlxwbWLNpzg19xTmvBiXDFlKIjlwuUkEjG7pVKK8g/owLabK3CfqMk0Fg== X-Received: by 2002:a05:622a:1ba7:b0:31e:c153:646b with SMTP id bp39-20020a05622a1ba700b0031ec153646bmr8550357qtb.283.1657815253836; Thu, 14 Jul 2022 09:14:13 -0700 (PDT) Received: from fedora.attlocal.net (69-109-179-158.lightspeed.dybhfl.sbcglobal.net. [69.109.179.158]) by smtp.gmail.com with ESMTPSA id cp4-20020a05622a420400b0031eb393aa45sm1690067qtb.40.2022.07.14.09.14.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jul 2022 09:14:13 -0700 (PDT) From: William Breathitt Gray To: gregkh@linuxfoundation.org Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, William Breathitt Gray Subject: [PATCH 4/4] MAINTAINERS: Update 104-QUAD-8 driver maintainers list Date: Thu, 14 Jul 2022 12:07:15 -0400 Message-Id: <53ecbe49e48dd142fc19f6436fdbe5b8573c5f9c.1657813472.git.william.gray@linaro.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Syed Nayyar Waris is no longer available for 104-QUAD-8 driver maintenance. William Breathitt Gray will continue as the 104-QUAD-8 driver maintainer. Signed-off-by: William Breathitt Gray --- MAINTAINERS | 1 - 1 file changed, 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index bb95b27f418d..22302d3bd7e8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -299,7 +299,6 @@ F: drivers/gpio/gpio-104-idio-16.c =20 ACCES 104-QUAD-8 DRIVER M: William Breathitt Gray -M: Syed Nayyar Waris L: linux-iio@vger.kernel.org S: Maintained F: drivers/counter/104-quad-8.c --=20 2.36.1