From patchwork Thu Mar 15 15:46:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Breathitt Gray X-Patchwork-Id: 886295 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="t+VQxzlA"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 402CfM09Gfz9sVL for ; Fri, 16 Mar 2018 02:47:55 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932383AbeCOPqw (ORCPT ); Thu, 15 Mar 2018 11:46:52 -0400 Received: from mail-yw0-f196.google.com ([209.85.161.196]:34208 "EHLO mail-yw0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752547AbeCOPqu (ORCPT ); Thu, 15 Mar 2018 11:46:50 -0400 Received: by mail-yw0-f196.google.com with SMTP id x17so4908944ywj.1; Thu, 15 Mar 2018 08:46:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oW7qoF0vCVNAEeVV6/d5z0FY+Hgb2Bn7ueLmM0QXAqA=; b=t+VQxzlAItpwtMnr8RShSSf+YCS9tglX4TwoJjWm77L2kTpshnWhY/sdB18LdVvdl0 Sbkbo3xxg5NGoqG+IfJVmyK6asyg9dA94BKooaKtjvTNlFad7WMUkcNLVpF6yQuzsPW0 n5hQKfujnmMNQVvRyP0syrJ0TtmBPtEWCG141Qb2oFEimM9cPZWTjTyrZS7ifNB7JbDf k6nMUbC6UpFDhs2NMB+iMmGFcxbXRpG0V8GtiO/E1aaI0v8WsmnvvLbzcsYpx5TdMZpd Oiz524G0P4FbpeKpkMCeBYSAeVYH9O3PMejPU5mRuWUcfkm53DwDxyfN6Q20oHKQjyot hpsA== 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:in-reply-to :references; bh=oW7qoF0vCVNAEeVV6/d5z0FY+Hgb2Bn7ueLmM0QXAqA=; b=jp0lYXVbkxvWFqA6oWPGNNLBNEvYmyjG7YSNiA7qvL+8Rn3Unstcnr/eK8m8QXDoTs UeNFZyQFu2EdYkclg4Yo8TxccY2eCfRXNZlp2714WaV8MnwERqN4UpAYXMPPj2VudfQG VwyP0XtG/6O4YcMVH8Nn+EFb3THT2LQBmpRCnjMKQ9UdlivkoDraVauE8cGlsj/od5Zd IWZDnZWquwX4MXMRd5fOcj5HXDf8A24FITjaqMeyt+/cdOP0gRgdVr0wO6T6u+exBuQl Nq68lUfCvnFxwLGDfRZ6MPjMrmCXY/rYhP17UBWwASlZschapyqAKBA9akbcHXELLsYA t9OA== X-Gm-Message-State: AElRT7GUXNoo20E9/7ApXxBAKH+lQA27GDSn+vHDy/1NSDNIXT015e7C 2uLRaRRnjoH5MTm2KJpaYwrJbQ== X-Google-Smtp-Source: AG47ELuBn0ZBQ3W4j2J2hNT7rlueH2OwmX7kV54j7AsyXFPOCfY9FMRUB+yD7Od1Q3U0o7X+KPJepQ== X-Received: by 2002:a25:2185:: with SMTP id h127-v6mr6156471ybh.36.1521128809626; Thu, 15 Mar 2018 08:46:49 -0700 (PDT) Received: from localhost ([72.188.97.40]) by smtp.gmail.com with ESMTPSA id p5sm1991343ywc.1.2018.03.15.08.46.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Mar 2018 08:46:49 -0700 (PDT) From: William Breathitt Gray To: linus.walleij@linaro.org Cc: andy.shevchenko@gmail.com, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, William Breathitt Gray , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Subject: [PATCH v2 1/8] iio: stx104: Implement get_multiple callback Date: Thu, 15 Mar 2018 11:46:37 -0400 Message-Id: <14a09900bf4642495ebe4072b9eb02769dbc4c5e.1521128287.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: References: Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The Apex Embedded Systems STX104 series of devices provides 4 TTL compatible lines of inputs accessed via a single 4-bit port. Since four input lines are acquired on a single port input read, the STX104 GPIO driver may improve multiple input reads by utilizing a get_multiple callback. This patch implements the stx104_gpio_get_multiple function which serves as the respective get_multiple callback. Cc: Jonathan Cameron Cc: Hartmut Knaack Cc: Lars-Peter Clausen Cc: Peter Meerwald-Stadler Signed-off-by: William Breathitt Gray --- drivers/iio/adc/stx104.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/iio/adc/stx104.c b/drivers/iio/adc/stx104.c index 17b021f33180..0662ca199eb0 100644 --- a/drivers/iio/adc/stx104.c +++ b/drivers/iio/adc/stx104.c @@ -233,6 +233,16 @@ static int stx104_gpio_get(struct gpio_chip *chip, unsigned int offset) return !!(inb(stx104gpio->base) & BIT(offset)); } +static int stx104_gpio_get_multiple(struct gpio_chip *chip, unsigned long *mask, + unsigned long *bits) +{ + struct stx104_gpio *const stx104gpio = gpiochip_get_data(chip); + + *bits = inb(stx104gpio->base); + + return 0; +} + static void stx104_gpio_set(struct gpio_chip *chip, unsigned int offset, int value) { @@ -342,6 +352,7 @@ static int stx104_probe(struct device *dev, unsigned int id) stx104gpio->chip.direction_input = stx104_gpio_direction_input; stx104gpio->chip.direction_output = stx104_gpio_direction_output; stx104gpio->chip.get = stx104_gpio_get; + stx104gpio->chip.get_multiple = stx104_gpio_get_multiple; stx104gpio->chip.set = stx104_gpio_set; stx104gpio->chip.set_multiple = stx104_gpio_set_multiple; stx104gpio->base = base[id] + 3; From patchwork Thu Mar 15 15:46:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Breathitt Gray X-Patchwork-Id: 886293 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="CnxkFjgZ"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 402Cdb4lG0z9sVK for ; Fri, 16 Mar 2018 02:47:15 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932645AbeCOPrD (ORCPT ); Thu, 15 Mar 2018 11:47:03 -0400 Received: from mail-yw0-f196.google.com ([209.85.161.196]:41196 "EHLO mail-yw0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932427AbeCOPrB (ORCPT ); Thu, 15 Mar 2018 11:47:01 -0400 Received: by mail-yw0-f196.google.com with SMTP id w12so4898522ywa.8; Thu, 15 Mar 2018 08:47:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5S57FZrDn18lTmUv3cK/UjtCHjKej2R0jpXyStLW50c=; b=CnxkFjgZaHXIEfsqapDWQ8rOAoLNIb25JHbTqRCojiLT9YatSjR5zQaDu4vNWzmtQb iIpTrNVEo61qx2o5IX21aPGz+AMWQkh6eSrBYxP1cLmKjBtNmmbSHIfbPp78AuRKeJMc PWVcmuP7niMYRG46FKG80EutZOuVjWkAgSoV0jrzsyXX6rbjZ/2Zr0E+ChDTA8FY2MRV IZ2k/GP90EAzaFhc3hp7ELVhGeAJWQ+2dD4F5s2hB5n941YbbaGIZhO+4R5HL3SqPJQB LLovIS3IUxsoctvd3ODFj+OUh0OzaWhmkZfu7Hjt4TBhgevbNjMp2QNxBXi8ljJ3fJ/x lxIA== 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:in-reply-to :references; bh=5S57FZrDn18lTmUv3cK/UjtCHjKej2R0jpXyStLW50c=; b=GnCBovAreUHYNvMn5Hx7sxoMn8Uxc/63SQBGON/io15L46Y0jRzDU9BQn/eqLglZeU Tg212zcXZOQg6vMMICgK8nXd0Q9I812IHZl+l1lctFgdpaLh69rd4/QOlLZKTD2LhAtn YI6CrjE244H6GqgtPN0fypQe2YpmaU6yBs3c0MFWVewaODNNmGdbo7XltpzuihhViGL2 N5tnke4bCOZyCJDpl6IaCHzdF2TMjNWTGF+8fM36SsjCQeQuXe2u7BQI1nvpif80GeWd TOSokbXRMvQBNt+xceT4Ceh3BLmE1jFGZUpaZqu5Req26BdLyVWug6ELjYxE/VYwPKXy lHKA== X-Gm-Message-State: AElRT7GhOR58YuiTdY1fILpalDOTmlhxBR0SyumzXl07HU8JiZ+rKY68 KH0kE1eUntP35heNMQNfUj79wg== X-Google-Smtp-Source: AG47ELsusxOt6zuanODwmjCx+6Vxpcj15RZpGb45/jswpIUeGhowDD/Ci/0Y//Jyvzvcpk/eeZbEmQ== X-Received: by 2002:a25:6843:: with SMTP id d64-v6mr991636ybc.268.1521128820386; Thu, 15 Mar 2018 08:47:00 -0700 (PDT) Received: from localhost ([72.188.97.40]) by smtp.gmail.com with ESMTPSA id i123sm124624ywd.73.2018.03.15.08.46.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Mar 2018 08:46:59 -0700 (PDT) From: William Breathitt Gray To: linus.walleij@linaro.org Cc: andy.shevchenko@gmail.com, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, William Breathitt Gray Subject: [PATCH v2 2/8] gpio: 104-idio-16: Implement get_multiple callback Date: Thu, 15 Mar 2018 11:46:54 -0400 Message-Id: <486eb9bad0440ed305a78d9fc990728cbeb7d43e.1521128287.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: References: Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The ACCES I/O 104-IDIO-16 series of devices provides 16 optically-isolated digital inputs accessed via two 8-bit ports. Since eight input lines are acquired on a single port input read, the 104-IDIO-16 GPIO driver may improve multiple input reads by utilizing a get_multiple callback. This patch implements the idio_16_gpio_get_multiple function which serves as the respective get_multiple callback. Signed-off-by: William Breathitt Gray --- drivers/gpio/gpio-104-idio-16.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/gpio/gpio-104-idio-16.c b/drivers/gpio/gpio-104-idio-16.c index 2f16638a0589..5de5819e5156 100644 --- a/drivers/gpio/gpio-104-idio-16.c +++ b/drivers/gpio/gpio-104-idio-16.c @@ -90,6 +90,20 @@ static int idio_16_gpio_get(struct gpio_chip *chip, unsigned offset) return !!(inb(idio16gpio->base + 5) & (mask>>8)); } +static int idio_16_gpio_get_multiple(struct gpio_chip *chip, + unsigned long *mask, unsigned long *bits) +{ + struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip); + + *bits = 0; + if (*mask & 0xFF0000) + *bits |= (unsigned long)inb(idio16gpio->base + 1) << 16; + if (*mask & 0xFF000000) + *bits |= (unsigned long)inb(idio16gpio->base + 5) << 24; + + return 0; +} + static void idio_16_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip); @@ -244,6 +258,7 @@ static int idio_16_probe(struct device *dev, unsigned int id) idio16gpio->chip.direction_input = idio_16_gpio_direction_input; idio16gpio->chip.direction_output = idio_16_gpio_direction_output; idio16gpio->chip.get = idio_16_gpio_get; + idio16gpio->chip.get_multiple = idio_16_gpio_get_multiple; idio16gpio->chip.set = idio_16_gpio_set; idio16gpio->chip.set_multiple = idio_16_gpio_set_multiple; idio16gpio->base = base[id]; From patchwork Thu Mar 15 15:47:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Breathitt Gray X-Patchwork-Id: 886294 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="GYq83h8u"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 402CfL2Hk3z9sVK for ; Fri, 16 Mar 2018 02:47:54 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932522AbeCOPrU (ORCPT ); Thu, 15 Mar 2018 11:47:20 -0400 Received: from mail-yw0-f193.google.com ([209.85.161.193]:41227 "EHLO mail-yw0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932427AbeCOPrS (ORCPT ); Thu, 15 Mar 2018 11:47:18 -0400 Received: by mail-yw0-f193.google.com with SMTP id w12so4899192ywa.8; Thu, 15 Mar 2018 08:47:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oaC+eeSvETSipBZQ8G9tGZdQO0J0x1rT3ToK/tMEqww=; b=GYq83h8uxmqshYOBrI9RSWzFK1l6eWQTV07c6EIQJm5GLWIPlSu4I/Cli+W9zAYrUj saepf4CSyunEWKBQXC9t3P6kPKX2JI9irxSNNx2Xc7zh6x2p0hxW98VLvQlbBIJl18xI Qohy+EGv2NgmHRlvtPOSOg8FZ17VCU5jo4mO1Vt5LMN8gNaW3NbTlA0OKUbiCOyFKI/G 9bdzaZfqu0we5gWmmWTbQSzcHepb1Tl7sTBqgVjabQcorl2CnKUDmpV2v9PLbjI6siGW N2F0cuMBgkRLGN7WJwKseyguvA2YNA59yD+Rd6bmAKb4q9vJUDEMucAQedWjui+nhA5N vkzg== 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:in-reply-to :references; bh=oaC+eeSvETSipBZQ8G9tGZdQO0J0x1rT3ToK/tMEqww=; b=IzK9J2OnOfKe3OC+uEQVOp4/GdetvS7fJDbKjNr2Ve0R6xxPC6nzMlIDDLedRlYCL6 kn6vrMh6shp96+fyb/h2BjzutzjoNekt+Db9rYKwpIkU0lB7357ZQrrXDv6MjZP60joP BLrRqYZSvhMlsyYOnFZuO0EiMA32aBgqCx/4iDaNgKxBGjjk+Q71mqHRnXuSLM5Cgem0 RmAob+MTJsexhYB0oanEg0qz2Od4yx67acKLopPsWoAg4MhWUlZqmpxcmUrh2rDkU2ew LK/eEUufbUwX1yCcu+SdKDa2/SJnMA5lNS88VYEP83FiLRRd+ube8YZHyP2r8kfLzgmF ns1Q== X-Gm-Message-State: AElRT7EyBUzbN+/ORxmPoOtjKL9lvCyvCXY0bz2mg6DALOQCyUmhHCkN LckbHqtv4Sg6Hx2p1qOaK9E= X-Google-Smtp-Source: AG47ELvuFFiJVzMXfm4iiafJ62/+p7Yk+4FjEm1cQrFyC4hUH8DlJNBrAcjZaHhJoOSa4TF4ZT/low== X-Received: by 10.13.209.132 with SMTP id t126mr1492493ywd.126.1521128837519; Thu, 15 Mar 2018 08:47:17 -0700 (PDT) Received: from localhost ([72.188.97.40]) by smtp.gmail.com with ESMTPSA id t131sm1972753ywe.77.2018.03.15.08.47.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Mar 2018 08:47:16 -0700 (PDT) From: William Breathitt Gray To: linus.walleij@linaro.org Cc: andy.shevchenko@gmail.com, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, William Breathitt Gray Subject: [PATCH v2 3/8] gpio: pci-idio-16: Implement get_multiple callback Date: Thu, 15 Mar 2018 11:47:11 -0400 Message-Id: X-Mailer: git-send-email 2.16.2 In-Reply-To: References: Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The ACCES I/O PCI-IDIO-16 series of devices provides 16 optically-isolated digital inputs accessed via two 8-bit ports. Since eight input lines are acquired on a single port input read, the PCI-IDIO-16 GPIO driver may improve multiple input reads by utilizing a get_multiple callback. This patch implements the idio_16_gpio_get_multiple function which serves as the respective get_multiple callback. Signed-off-by: William Breathitt Gray --- drivers/gpio/gpio-pci-idio-16.c | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/drivers/gpio/gpio-pci-idio-16.c b/drivers/gpio/gpio-pci-idio-16.c index 57d1b7fbf07b..ef43a37ccaff 100644 --- a/drivers/gpio/gpio-pci-idio-16.c +++ b/drivers/gpio/gpio-pci-idio-16.c @@ -11,6 +11,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. */ +#include #include #include #include @@ -103,6 +104,54 @@ static int idio_16_gpio_get(struct gpio_chip *chip, unsigned int offset) return !!(ioread8(&idio16gpio->reg->in8_15) & (mask >> 24)); } +static int idio_16_gpio_get_multiple(struct gpio_chip *chip, + unsigned long *mask, unsigned long *bits) +{ + struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip); + size_t i; + const unsigned int gpio_reg_size = 8; + unsigned int bits_offset; + size_t word_index; + unsigned int word_offset; + unsigned long mask_word; + const unsigned long port_mask = GENMASK(gpio_reg_size, 0); + unsigned long port_state; + const u8 __iomem ports[] = { + idio16gpio->reg->out0_7, idio16gpio->reg->out8_15, + idio16gpio->reg->in0_7, idio16gpio->reg->in8_15 + }; + + /* clear bits array to a clean slate */ + bitmap_zero(bits, chip->ngpio); + + /* get bits are evaluated a gpio port register at a time */ + for (i = 0; i < ARRAY_SIZE(ports); i++) { + /* gpio offset in bits array */ + bits_offset = i * gpio_reg_size; + + /* word index for bits array */ + word_index = BIT_WORD(bits_offset); + + /* gpio offset within current word of bits array */ + word_offset = bits_offset % BITS_PER_LONG; + + /* mask of get bits for current gpio within current word */ + word_mask = mask[word_index] & (port_mask << word_offset); + if (!word_mask) { + /* no get bits in this port so skip to next one */ + continue; + } + + /* read bits from current gpio port */ + port_state = ioread8(ports + i); + + /* store acquired bits at respective bits array offset */ + bits[word_index] |= port_state << word_offset; + } + + return 0; +} + static void idio_16_gpio_set(struct gpio_chip *chip, unsigned int offset, int value) { @@ -299,6 +348,7 @@ static int idio_16_probe(struct pci_dev *pdev, const struct pci_device_id *id) idio16gpio->chip.direction_input = idio_16_gpio_direction_input; idio16gpio->chip.direction_output = idio_16_gpio_direction_output; idio16gpio->chip.get = idio_16_gpio_get; + idio16gpio->chip.get_multiple = idio_16_gpio_get_multiple; idio16gpio->chip.set = idio_16_gpio_set; idio16gpio->chip.set_multiple = idio_16_gpio_set_multiple; From patchwork Thu Mar 15 15:52:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Breathitt Gray X-Patchwork-Id: 886305 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Q2asE4q0"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 402CmT1hmMz9sVL for ; Fri, 16 Mar 2018 02:53:13 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932458AbeCOPw7 (ORCPT ); Thu, 15 Mar 2018 11:52:59 -0400 Received: from mail-yw0-f196.google.com ([209.85.161.196]:44084 "EHLO mail-yw0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932404AbeCOPw5 (ORCPT ); Thu, 15 Mar 2018 11:52:57 -0400 Received: by mail-yw0-f196.google.com with SMTP id x197so4899020ywg.11; Thu, 15 Mar 2018 08:52:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wkU5ZyNLgeRbt2NLKzHaXA7AeRJLDE8g1xRckDbikVk=; b=Q2asE4q0toH+tWdJ4iQQUeO77hHXXSHw+xWeB/hdVLX4wbiLp7kTfispObQtY+iOYf QCpdv5NpaB75Ox8aR6qtqBVTtMrqKPk/k629vqFEdDsnlYu6u+Zwvefashf0oG/Kq69F kO0F3/6ip7E6enw8NKI8lx8gHxPQMpRjxKKZD/rQV56Jb12ALhZR5Ev3lCVi3qCn9sx9 bHIqdScqpw3pYuvyZyvc7HRMV56ZWmtIigESRGS21O3NSvwc8HPAA65Vc6G6tOSMx9BM NdhHSSB3hr+vOINNdDMicTo+VeoqPsorYCakZ53MIo9lCzoXlM4n0IsvHWANr2diA0qP 0+9w== 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:in-reply-to :references; bh=wkU5ZyNLgeRbt2NLKzHaXA7AeRJLDE8g1xRckDbikVk=; b=Yfu63R0VAulmed2y0Y1LjP8ez4lxr1ZFSSQQ6dchdgZhi4EG9sXm3Yng0WSIGUtzo1 DUeHCJZbLSriQgEUxCUJz9jHqZDpv4SA6ZrB7uVqyigCGbVvMbE+pYOmdA8h/Hm2i5ER 9IPmhIHjfZJK+j6RSE8J3ymliWVTDuFD29uu6qyGxl6P/hfyez0nx+qEFTerCnwtgsm+ sHMSVMwV8/KDFrYepapNcOnDfYa8dgSklH6i+Kdz4A0NWws/oYqvRFQRNQsFVTimLNFJ DxDnusN4ssuuze26BNF/HCh4F4YPLkL9TTbCP67FxevpNwdIjGcRovhu3a3eTDly8417 l9aA== X-Gm-Message-State: AElRT7EdThM/DiR442bKAXJbpKI9G3MEq6rz0tNAWwSOWmVcBzD+ROe0 YZGP6pVPuuCTsRc4HE1m8ahd9A== X-Google-Smtp-Source: AG47ELvYNPT4UOPN+grBlzDFk7vepCxzXVJvSg+kSnrmMg+g+RFdyikiKTHcUmkxy0GR3bHhU3j/mQ== X-Received: by 2002:a25:80d1:: with SMTP id c17-v6mr6160527ybm.327.1521129176219; Thu, 15 Mar 2018 08:52:56 -0700 (PDT) Received: from localhost ([72.188.97.40]) by smtp.gmail.com with ESMTPSA id p204sm2020833ywg.71.2018.03.15.08.52.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Mar 2018 08:52:55 -0700 (PDT) From: William Breathitt Gray To: linus.walleij@linaro.org Cc: andy.shevchenko@gmail.com, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, William Breathitt Gray Subject: [PATCH v2 4/8] gpio: pcie-idio-24: Implement get_multiple/set_multiple callbacks Date: Thu, 15 Mar 2018 11:52:44 -0400 Message-Id: <41c682a781e20b2db55491d36d600d56bb6b5c66.1521128287.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: References: Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The ACCES I/O PCIe-IDIO-24 series of devices provides 24 optically-isolated digital I/O accessed via six 8-bit ports. Since eight input lines are acquired on a single port input read -- and similarly eight output lines are set on a single port output write -- the PCIe-IDIO-24 GPIO driver may improve multiple I/O reads/writes by utilizing a get_multiple/set_multiple callbacks. This patch implements the idio_24_gpio_get_multiple function which serves as the respective get_multiple callback, and implements the idio_24_gpio_set_multiple function which serves as the respective set_multiple callback. Signed-off-by: William Breathitt Gray --- drivers/gpio/gpio-pcie-idio-24.c | 118 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/drivers/gpio/gpio-pcie-idio-24.c b/drivers/gpio/gpio-pcie-idio-24.c index f666e2e69074..8d2f4745a13c 100644 --- a/drivers/gpio/gpio-pcie-idio-24.c +++ b/drivers/gpio/gpio-pcie-idio-24.c @@ -15,6 +15,7 @@ * This driver supports the following ACCES devices: PCIe-IDIO-24, * PCIe-IDI-24, PCIe-IDO-24, and PCIe-IDIO-12. */ +#include #include #include #include @@ -193,6 +194,61 @@ static int idio_24_gpio_get(struct gpio_chip *chip, unsigned int offset) return !!(ioread8(&idio24gpio->reg->ttl_in0_7) & offset_mask); } +static int idio_24_gpio_get_multiple(struct gpio_chip *chip, + unsigned long *mask, unsigned long *bits) +{ + struct idio_24_gpio *const idio24gpio = gpiochip_get_data(chip); + size_t i; + const unsigned int gpio_reg_size = 8; + unsigned int bits_offset; + size_t word_index; + unsigned int word_offset; + unsigned long mask_word; + const unsigned long port_mask = GENMASK(gpio_reg_size, 0); + unsigned long port_state; + const u8 __iomem ports[] = { + idio24gpio->reg->out0_7, idio24gpio->reg->out8_15, + idio24gpio->reg->out16_23, idio24gpio->reg->in0_7, + idio24gpio->reg->in8_15, idio24gpio->reg->in16_23 + }; + const unsigned long out_mode_mask = BIT(1); + + /* clear bits array to a clean slate */ + bitmap_zero(bits, chip->ngpio); + + /* get bits are evaluated a gpio port register at a time */ + for (i = 0; i < ARRAY_SIZE(ports); i++) { + /* gpio offset in bits array */ + bits_offset = i * gpio_reg_size; + + /* word index for bits array */ + word_index = BIT_WORD(bits_offset); + + /* gpio offset within current word of bits array */ + word_offset = bits_offset % BITS_PER_LONG; + + /* mask of get bits for current gpio within current word */ + word_mask = mask[word_index] & (port_mask << word_offset); + if (!word_mask) { + /* no get bits in this port so skip to next one */ + continue; + } + + /* read bits from current gpio port (port 6 is TTL GPIO) */ + if (i < 6) + port_state = ioread8(ports + i); + else if (ioread8(&idio24gpio->reg->ctl) & out_mode_mask) + port_state = ioread8(&idio24gpio->reg->ttl_out0_7); + else + port_state = ioread8(&idio24gpio->reg->ttl_in0_7); + + /* store acquired bits at respective bits array offset */ + bits[word_index] |= port_state << word_offset; + } + + return 0; +} + static void idio_24_gpio_set(struct gpio_chip *chip, unsigned int offset, int value) { @@ -234,6 +290,66 @@ static void idio_24_gpio_set(struct gpio_chip *chip, unsigned int offset, raw_spin_unlock_irqrestore(&idio24gpio->lock, flags); } +static void idio_24_gpio_set_multiple(struct gpio_chip *chip, + unsigned long *mask, unsigned long *bits) +{ + struct idio_24_gpio *const idio24gpio = gpiochip_get_data(chip); + size_t i; + unsigned long bits_offset; + unsigned long gpio_mask; + const unsigned int gpio_reg_size = 8; + const unsigned long port_mask = GENMASK(gpio_reg_size, 0); + unsigned long gpio_mask; + unsigned long flags; + unsigned int out_state; + const u8 __iomem ports[] = { + idio24gpio->reg->out0_7, idio24gpio->reg->out8_15, + idio24gpio->reg->out16_23 + }; + const unsigned long out_mode_mask = BIT(1); + const unsigned int ttl_offset = 48; + const size_t ttl_i = BIT_WORD(ttl_offset); + const unsigned int word_offset = ttl_offset % BITS_PER_LONG; + const unsigned long ttl_mask = (mask[ttl_i] >> word_offset) & port_mask; + const unsigned long ttl_bits = (bits[ttl_i] >> word_offset) & ttl_mask; + + /* set bits are processed a gpio port register at a time */ + for (i = 0; i < ARRAY_SIZE(ports); i++) { + /* gpio offset in bits array */ + bits_offset = i * gpio_reg_size; + + /* check if any set bits for current port */ + gpio_mask = (*mask >> bits_offset) & port_mask; + if (!gpio_mask) { + /* no set bits for this port so move on to next port */ + continue; + } + + raw_spin_lock_irqsave(&idio24gpio->lock, flags); + + /* process output lines */ + out_state = ioread8(ports + i) & ~gpio_mask; + out_state |= (*bits >> bits_offset) & gpio_mask; + iowrite8(out_state, ports + i); + + raw_spin_unlock_irqrestore(&idio24gpio->lock, flags); + } + + /* check if setting TTL lines and if they are in output mode */ + if (!ttl_mask || !(ioread8(&idio24gpio->reg->ctl) & out_mode_mask)) + return; + + /* handle TTL output */ + raw_spin_lock_irqsave(&idio24gpio->lock, flags); + + /* process output lines */ + out_state = ioread8(&idio24gpio->reg->ttl_out0_7) & ~ttl_mask; + out_state |= ttl_bits; + iowrite8(out_state, &idio24gpio->reg->ttl_out0_7); + + raw_spin_unlock_irqrestore(&idio24gpio->lock, flags); +} + static void idio_24_irq_ack(struct irq_data *data) { } @@ -397,7 +513,9 @@ static int idio_24_probe(struct pci_dev *pdev, const struct pci_device_id *id) idio24gpio->chip.direction_input = idio_24_gpio_direction_input; idio24gpio->chip.direction_output = idio_24_gpio_direction_output; idio24gpio->chip.get = idio_24_gpio_get; + idio24gpio->chip.get_multiple = idio_24_gpio_get_multiple; idio24gpio->chip.set = idio_24_gpio_set; + idio24gpio->chip.set = idio_24_gpio_set_multiple; raw_spin_lock_init(&idio24gpio->lock); From patchwork Thu Mar 15 15:53:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Breathitt Gray X-Patchwork-Id: 886311 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gs5q09rn"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 402Cq21hRVz9s2M for ; Fri, 16 Mar 2018 02:55:26 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932451AbeCOPxO (ORCPT ); Thu, 15 Mar 2018 11:53:14 -0400 Received: from mail-yw0-f194.google.com ([209.85.161.194]:34003 "EHLO mail-yw0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932404AbeCOPxM (ORCPT ); Thu, 15 Mar 2018 11:53:12 -0400 Received: by mail-yw0-f194.google.com with SMTP id x17so4924236ywj.1; Thu, 15 Mar 2018 08:53:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IJYRNcOUEvbElAD43QFb+n+SUBEKYb1yA+zEXAuUoxI=; b=gs5q09rnJuh+uqqeueO6WSTBOCrdUlDPWIWP2fvESfyYLWVzQ27fBjJReoZ14JcSf0 iG6lTINgZCGdnWf+0qiFucugjRtPn1dSlz+HyCAIlbBLmPXOHdzGcONLW7ULVwCewqfS OQaSFLKQ5eG8cTWIF8IEXCXeixQ2eTcx7ax4iZeCf56tLEG2wsqEgjDZELi5WChSYgBw Doa5EAd9FOO6cu/fwDWjfFPS6Aztv+FRul/ETiqNW4/Mm2W0QvL9yallH/9bq74UpU/8 cnauzXtMbiFQXs08gofedCi4Jg4Xhp5RNnUjTsROjxDxnw1V+MIp0c742dJUxvH6NeCk yNow== 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:in-reply-to :references; bh=IJYRNcOUEvbElAD43QFb+n+SUBEKYb1yA+zEXAuUoxI=; b=ewejzgbdn1YqzmfrGnMeFQP1Iy+m4yBapFOgmBfKDPHWQIDlrvZpQ90HmgJqZrZz5c JMsL+NcXvE5gOHF7sdzq1URohAXDRvYNB8W/jjZcw7yAnRieCVlZW5CA9LjgRST/78aa a0oRIAAI7AuqlgbqjGIQPWjWZPux5k8k80GxxbilD4CMQ/RUhZbJ4gKLCGdD4Wx+vAaq ne4rX0MKCTfgsz4VhsrKX/wNpSIeqVse6gmntO5b+rEdkCCK1EAreKfkvGZJwdP6uPeu Vz00t4uwTuTPwLU+HgvrdzwWaOlkOtxOW6CoyT/BLwZr711EHH1M3QtVYXpoxQ6Vq/wO V8oQ== X-Gm-Message-State: AElRT7FC2V2mxe5r823Re3EhxiUo61lhV9jMG9sV2mFj6gBBxha9Xsou v0O8B3/C5d9U+lcMTNvbQDI= X-Google-Smtp-Source: AG47ELvaZWrlOJH74xGv2HMmqrcMAWD+DbEFOEwskBWb7RDU2mC5nz1wv7DhOh24bNdYgZLDgFMObg== X-Received: by 2002:a25:6dc2:: with SMTP id i185-v6mr6157675ybc.81.1521129191481; Thu, 15 Mar 2018 08:53:11 -0700 (PDT) Received: from localhost ([72.188.97.40]) by smtp.gmail.com with ESMTPSA id x133sm1933461ywc.27.2018.03.15.08.53.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Mar 2018 08:53:10 -0700 (PDT) From: William Breathitt Gray To: linus.walleij@linaro.org Cc: andy.shevchenko@gmail.com, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, William Breathitt Gray Subject: [PATCH v2 5/8] gpio: 104-dio-48e: Implement get_multiple callback Date: Thu, 15 Mar 2018 11:53:05 -0400 Message-Id: X-Mailer: git-send-email 2.16.2 In-Reply-To: References: Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The ACCES I/O 104-DIO-48E series of devices contain two Programmable Peripheral Interface (PPI) chips of type 82C55, which each feature three 8-bit ports of I/O. Since eight input lines are acquired on a single port input read, the 104-DIO-48E GPIO driver may improve multiple input reads by utilizing a get_multiple callback. This patch implements the dio48e_gpio_get_multiple function which serves as the respective get_multiple callback. Signed-off-by: William Breathitt Gray --- drivers/gpio/gpio-104-dio-48e.c | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/gpio/gpio-104-dio-48e.c b/drivers/gpio/gpio-104-dio-48e.c index bab3b94c5cbc..537b436c6e7f 100644 --- a/drivers/gpio/gpio-104-dio-48e.c +++ b/drivers/gpio/gpio-104-dio-48e.c @@ -182,6 +182,51 @@ static int dio48e_gpio_get(struct gpio_chip *chip, unsigned offset) return !!(port_state & mask); } +static int dio48e_gpio_get_multiple(struct gpio_chip *chip, unsigned long *mask, + unsigned long *bits) +{ + struct dio48e_gpio *const dio48egpio = gpiochip_get_data(chip); + size_t i; + const size_t ports[] = { 0, 1, 2, 4, 5, 6 }; + const unsigned int gpio_reg_size = 8; + unsigned int bits_offset; + size_t word_index; + unsigned int word_offset; + unsigned long mask_word; + const unsigned long port_mask = GENMASK(gpio_reg_size, 0); + unsigned long port_state; + + /* clear bits array to a clean slate */ + bitmap_zero(bits, chip->ngpio); + + /* get bits are evaluated a gpio port register at a time */ + for (i = 0; i < ARRAY_SIZE(ports); i++) { + /* gpio offset in bits array */ + bits_offset = i * gpio_reg_size; + + /* word index for bits array */ + word_index = BIT_WORD(bits_offset); + + /* gpio offset within current word of bits array */ + word_offset = bits_offset % BITS_PER_LONG; + + /* mask of get bits for current gpio within current word */ + word_mask = mask[word_index] & (port_mask << word_offset); + if (!word_mask) { + /* no get bits in this port so skip to next one */ + continue; + } + + /* read bits from current gpio port */ + port_state = inb(dio48egpio->base + ports[i]); + + /* store acquired bits at respective bits array offset */ + bits[word_index] |= port_state << word_offset; + } + + return 0; +} + static void dio48e_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { struct dio48e_gpio *const dio48egpio = gpiochip_get_data(chip); @@ -384,6 +429,7 @@ static int dio48e_probe(struct device *dev, unsigned int id) dio48egpio->chip.direction_input = dio48e_gpio_direction_input; dio48egpio->chip.direction_output = dio48e_gpio_direction_output; dio48egpio->chip.get = dio48e_gpio_get; + dio48egpio->chip.get_multiple = dio48e_gpio_get_multiple; dio48egpio->chip.set = dio48e_gpio_set; dio48egpio->chip.set_multiple = dio48e_gpio_set_multiple; dio48egpio->base = base[id]; From patchwork Thu Mar 15 15:53:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Breathitt Gray X-Patchwork-Id: 886309 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Gby6Ug+Z"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 402Cnj02xvz9s2M for ; Fri, 16 Mar 2018 02:54:17 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932404AbeCOPxZ (ORCPT ); Thu, 15 Mar 2018 11:53:25 -0400 Received: from mail-yw0-f193.google.com ([209.85.161.193]:35829 "EHLO mail-yw0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932755AbeCOPxY (ORCPT ); Thu, 15 Mar 2018 11:53:24 -0400 Received: by mail-yw0-f193.google.com with SMTP id c20so4927582ywa.2; Thu, 15 Mar 2018 08:53:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rGzDOGiFHbXxrpPvsk2rmMzjICyw2CxgzfYECs2EGrU=; b=Gby6Ug+ZHxa9xSX3116XI/H6TTYHTu/tTEIbp7Ucp4EjeQgepwzJWRwPqTwRDfS5Zc M7jKrD6AbU4L16iHOhGVjhBOYRkz2J4mXZewWyh4pOjooX3FOtJPAwkVpNk87ww71FCr pq6oeWf9IDjRjStXACdbdmpA7aBoB8ak8dZobBZd+HN2pqb16tGtsbu5sgQJLEGCVjAT iEbTJkanSy7witg/0q6H9Q3NeWM7lI1giQl3vIkQBhMTZTwRF/S9HgJRarzDg5k3loKi dO6Sv/tuQcwp0A5tN0dGaoC5cKoc1UixB0sQ5EyCZvASHafi1TqkGO1VbqwQBq4+d/+X ZGKg== 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:in-reply-to :references; bh=rGzDOGiFHbXxrpPvsk2rmMzjICyw2CxgzfYECs2EGrU=; b=iJn38ifibzx8aQE3eBGeIndNBISmhJrXVAsaXMXB1pLE+TYF/haZE6fcDym8XxpxSb soi7BsVt/CAPWnRFx+ar5B5GIM9aD8AZD9h/qLSZQ5BJSFe1dtX3Vqhpn9wQhflG2yK7 2ssWilnlgsT59lQgxnj2mttHElq0+cDwKWsMNfCDBvIqmIoQGfd47OxR5x5K5jK0x0uv k2Qa79WH5sgzOeu7/oXJera/USWVRiWQAAy9KbXDttepDp4icVBfpdrdzSAp/nnZlyca Qz3h9BCMF7WVcklwSS0AOHh9owA4AY5zSrhebhKO9Rjnw7Lr/yp4i3s2tSleqQ23VkVJ pZ4g== X-Gm-Message-State: AElRT7H1ALdKC10zMp8tDd2L9LMaFpXHCTpr0J8HkmM7yDTyVa9cF2W1 lIJx2eXwRNLP5OkDp2Jb5Mo= X-Google-Smtp-Source: AG47ELsxvKAemJIobekbrLGhc8f38kWTRpHqvqMwTus/woXdNHn//w1CzDMW8h+z/maA/7vUiQzLyg== X-Received: by 2002:a25:ad96:: with SMTP id z22-v6mr6142115ybi.296.1521129203836; Thu, 15 Mar 2018 08:53:23 -0700 (PDT) Received: from localhost ([72.188.97.40]) by smtp.gmail.com with ESMTPSA id y195sm2071527ywy.103.2018.03.15.08.53.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Mar 2018 08:53:23 -0700 (PDT) From: William Breathitt Gray To: linus.walleij@linaro.org Cc: andy.shevchenko@gmail.com, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, William Breathitt Gray Subject: [PATCH v2 6/8] gpio: 104-idi-48: Implement get_multiple callback Date: Thu, 15 Mar 2018 11:53:17 -0400 Message-Id: <5ec68441ce758b17c21264a1a1bb5ab98b5263e8.1521128287.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: References: Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The ACCES I/O 104-IDI-48 series of devices provides 48 optically-isolated inputs accessed via six 8-bit ports. Since eight input lines are acquired on a single port input read, the 104-IDI-48 GPIO driver may improve multiple input reads by utilizing a get_multiple callback. This patch implements the idi_48_gpio_get_multiple function which serves as the respective get_multiple callback. Signed-off-by: William Breathitt Gray --- drivers/gpio/gpio-104-idi-48.c | 46 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c index add859d59766..1beb6b0591ee 100644 --- a/drivers/gpio/gpio-104-idi-48.c +++ b/drivers/gpio/gpio-104-idi-48.c @@ -88,6 +88,51 @@ static int idi_48_gpio_get(struct gpio_chip *chip, unsigned offset) return 0; } +static int idi_48_gpio_get_multiple(struct gpio_chip *chip, unsigned long *mask, + unsigned long *bits) +{ + struct idi_48_gpio *const idi48gpio = gpiochip_get_data(chip); + size_t i; + const size_t ports[] = { 0, 1, 2, 4, 5, 6 }; + const unsigned int gpio_reg_size = 8; + unsigned int bits_offset; + size_t word_index; + unsigned int word_offset; + unsigned long mask_word; + const unsigned long port_mask = GENMASK(gpio_reg_size, 0); + unsigned long port_state; + + /* clear bits array to a clean slate */ + bitmap_zero(bits, chip->ngpio); + + /* get bits are evaluated a gpio port register at a time */ + for (i = 0; i < ARRAY_SIZE(ports); i++) { + /* gpio offset in bits array */ + bits_offset = i * gpio_reg_size; + + /* word index for bits array */ + word_index = BIT_WORD(bits_offset); + + /* gpio offset within current word of bits array */ + word_offset = bits_offset % BITS_PER_LONG; + + /* mask of get bits for current gpio within current word */ + word_mask = mask[word_index] & (port_mask << word_offset); + if (!word_mask) { + /* no get bits in this port so skip to next one */ + continue; + } + + /* read bits from current gpio port */ + port_state = inb(idi48egpio->base + ports[i]); + + /* store acquired bits at respective bits array offset */ + bits[word_index] |= port_state << word_offset; + } + + return 0; +} + static void idi_48_irq_ack(struct irq_data *data) { } @@ -256,6 +301,7 @@ static int idi_48_probe(struct device *dev, unsigned int id) idi48gpio->chip.get_direction = idi_48_gpio_get_direction; idi48gpio->chip.direction_input = idi_48_gpio_direction_input; idi48gpio->chip.get = idi_48_gpio_get; + idi48gpio->chip.get_multiple = idi_48_gpio_get_multiple; idi48gpio->base = base[id]; raw_spin_lock_init(&idi48gpio->lock); From patchwork Thu Mar 15 15:53:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Breathitt Gray X-Patchwork-Id: 886308 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dYFy+Hdb"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 402CnX71g8z9sVj for ; Fri, 16 Mar 2018 02:54:08 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932806AbeCOPxi (ORCPT ); Thu, 15 Mar 2018 11:53:38 -0400 Received: from mail-yw0-f193.google.com ([209.85.161.193]:38202 "EHLO mail-yw0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932665AbeCOPxf (ORCPT ); Thu, 15 Mar 2018 11:53:35 -0400 Received: by mail-yw0-f193.google.com with SMTP id y203so4919793ywg.5; Thu, 15 Mar 2018 08:53:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yFrvuwmF4wZClOqqeNrQ4n6lVfIANwYffSZYqb93XBg=; b=dYFy+HdbT3DOkPYGrjwQoVWkNIYPfJ2ElkAyhDdFoW5sXCnEYk/Api+sVyP/nDv8NB /zhMws8SNA2Z09xF++M5KLHt8BWNimB7YGLrw4kYGjl4eIt+Z0qWSA8p+FtCZp2Fil4L BaHoR5LzU+sPQslJUexKwTBZiT+MBbShrosod51p03QdsmSP/rURz9jE0WV6XgTrnneN hLSsvGoH+5IH+5KsnoAoZ45H3HW8SMWVj8k4Cf1W1O3cqqxCkzRXbRomZ3rABL8Uc44B 09379dEgVxgJosTxRzsZ8vjrGX36L0ehkwv62Or3OrMgfrh9gWgOuftNbGY5a6TBCYdb KTwA== 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:in-reply-to :references; bh=yFrvuwmF4wZClOqqeNrQ4n6lVfIANwYffSZYqb93XBg=; b=BauiMKtVzvKjilMM/k09dJHwRgB5mshLBB6TNghMpYPpJjd4D2tu+AkMYsELRaPEFZ J17JzsArCg4RWd1Kbn7H0k4aBGkyEQKsy1FOCPRrUORRW8KO0tgWOrWi69TznAnPcl+P YEDYEu3pka9Q0zGUFJgQ7pDuYiykfhLMLq9kH7jbol9HVA3m9qPSKkCT50Jdn2uuknGm gTfcQDcNVlgIN2jZte21CovpWiLoWiiyxKQ7/XyTfMs+yLjXJq3SKbIzRzgr4OwLpRXb ofJjuDsdCFxk5+Ri9F2oUgkNXjf+W9Avin5qcmpFiBQGkXoF5EnpOmNjj10rDN8Zmv1c pE/A== X-Gm-Message-State: AElRT7HaLgUzMtZpZk/lKTHKhZG9FQbuArHT29z++2kL55kK4PvICX9y rMqFK684lRsNHShlHITtzUGnMw== X-Google-Smtp-Source: AG47ELs6v6MGwjA1Q/KpaSCSCAogQFwMCR+a7vDTD93kkv7A7h2vY8u1OrGSh18LpI8kQT6QRZpKOQ== X-Received: by 10.129.226.65 with SMTP id z1mr6331357ywl.333.1521129214817; Thu, 15 Mar 2018 08:53:34 -0700 (PDT) Received: from localhost ([72.188.97.40]) by smtp.gmail.com with ESMTPSA id c15sm324855ywh.38.2018.03.15.08.53.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Mar 2018 08:53:34 -0700 (PDT) From: William Breathitt Gray To: linus.walleij@linaro.org Cc: andy.shevchenko@gmail.com, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, William Breathitt Gray Subject: [PATCH v2 7/8] gpio: gpio-mm: Implement get_multiple callback Date: Thu, 15 Mar 2018 11:53:28 -0400 Message-Id: X-Mailer: git-send-email 2.16.2 In-Reply-To: References: Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The Diamond Systems GPIO-MM series of devices contain two 82C55A devices, which each feature three 8-bit ports of I/O. Since eight input lines are acquired on a single port input read, the GPIO-MM GPIO driver may improve multiple input reads by utilizing a get_multiple callback. This patch implements the gpiomm_gpio_get_multiple function which serves as the respective get_multiple callback. Signed-off-by: William Breathitt Gray --- drivers/gpio/gpio-gpio-mm.c | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/gpio/gpio-gpio-mm.c b/drivers/gpio/gpio-gpio-mm.c index 11ade5b288f8..d9be9ebe41cf 100644 --- a/drivers/gpio/gpio-gpio-mm.c +++ b/drivers/gpio/gpio-gpio-mm.c @@ -171,6 +171,51 @@ static int gpiomm_gpio_get(struct gpio_chip *chip, unsigned int offset) return !!(port_state & mask); } +static int gpiomm_gpio_get_multiple(struct gpio_chip *chip, unsigned long *mask, + unsigned long *bits) +{ + struct gpiomm_gpio *const gpiommgpio = gpiochip_get_data(chip); + size_t i; + const size_t ports[] = { 0, 1, 2, 4, 5, 6 }; + const unsigned int gpio_reg_size = 8; + unsigned int bits_offset; + size_t word_index; + unsigned int word_offset; + unsigned long mask_word; + const unsigned long port_mask = GENMASK(gpio_reg_size, 0); + unsigned long port_state; + + /* clear bits array to a clean slate */ + bitmap_zero(bits, chip->ngpio); + + /* get bits are evaluated a gpio port register at a time */ + for (i = 0; i < ARRAY_SIZE(ports); i++) { + /* gpio offset in bits array */ + bits_offset = i * gpio_reg_size; + + /* word index for bits array */ + word_index = BIT_WORD(bits_offset); + + /* gpio offset within current word of bits array */ + word_offset = bits_offset % BITS_PER_LONG; + + /* mask of get bits for current gpio within current word */ + word_mask = mask[word_index] & (port_mask << word_offset); + if (!word_mask) { + /* no get bits in this port so skip to next one */ + continue; + } + + /* read bits from current gpio port */ + port_state = inb(gpiommgpio->base + ports[i]); + + /* store acquired bits at respective bits array offset */ + bits[word_index] |= port_state << word_offset; + } + + return 0; +} + static void gpiomm_gpio_set(struct gpio_chip *chip, unsigned int offset, int value) { @@ -268,6 +313,7 @@ static int gpiomm_probe(struct device *dev, unsigned int id) gpiommgpio->chip.direction_input = gpiomm_gpio_direction_input; gpiommgpio->chip.direction_output = gpiomm_gpio_direction_output; gpiommgpio->chip.get = gpiomm_gpio_get; + gpiommgpio->chip.get_multiple = gpiomm_gpio_get_multiple; gpiommgpio->chip.set = gpiomm_gpio_set; gpiommgpio->chip.set_multiple = gpiomm_gpio_set_multiple; gpiommgpio->base = base[id]; From patchwork Thu Mar 15 15:53:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Breathitt Gray X-Patchwork-Id: 886307 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OO6aWEHl"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 402CnS5xVWz9s2M for ; Fri, 16 Mar 2018 02:54:04 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932665AbeCOPxs (ORCPT ); Thu, 15 Mar 2018 11:53:48 -0400 Received: from mail-yw0-f193.google.com ([209.85.161.193]:43815 "EHLO mail-yw0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932469AbeCOPxq (ORCPT ); Thu, 15 Mar 2018 11:53:46 -0400 Received: by mail-yw0-f193.google.com with SMTP id r66so4908531ywh.10; Thu, 15 Mar 2018 08:53:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lCzlokA2J6QYPyk/ts+7WjOUPA7gImYP6yEkE4BG4l4=; b=OO6aWEHloVb/FHw9iFwWQugCQ1Lw4Xn3ALreIABY44gBF0nEkFf8yT/cXZzoSGnEq5 b5J61v+4oo1FP5caP9mkPI0kHwJQ0DRTLxV+VTxzxGfu2CHv2pySXxG8aJc1y65QnsA+ gDqzyH+kDglBgpUZ0K7lGVKIQ2gpw4aKB6xX8quxbr/mCljbhqzRPEWgnTR3I0vR2NOy qsRbqcBw7S2yd3HLpvxXYKOMi/LoVPRkweuOeUoBbNDZh1s7jaq3gseUr6lEU0f9kxN9 D3gD/F/5NqWV2cGRL1exdFpUqlfEf4/717rWZ5hnry9eKudufobwrYz7bGqv9Z8Wmros yceQ== 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:in-reply-to :references; bh=lCzlokA2J6QYPyk/ts+7WjOUPA7gImYP6yEkE4BG4l4=; b=WBFashrh9ccR8UpRXh5KDv64KfLpf9PhsFE0FSF2r4edTw4HRjlIcobsBvI9Tv7am/ pf7+YJQ5Ijo4L9Unjk8iZB6HAivbOU0Gox1U7dIuIYPj8wLSwPwdZYv7ggoICtHOgbzG VrI6z/hCzjHdyHWY0t0cT70cOplNgY3hpyNZ5QWxDjA2ARWPn2u1XmVTAit4+3sbYzns IKxx6wOo2mdhcVXbU3Jcn8MrOseM7pV8FF+/YSnOIuBbv2H5Emr7xxDA0fk3G1K5i/Fj cZheYKNRnqX6uaq7JBuSK4Yp7Cgq2HvkjcaBjLJanucsxV7vKkTRDh2e0SBQpw4odAhb Gu0Q== X-Gm-Message-State: AElRT7EsBZIGTaRH2q9q2Hv5c2xe5YIvK0ka52iVcR06KKS7UPVPS2St dl+3gJZdT6juBj3cF4IWRnM= X-Google-Smtp-Source: AG47ELvR1WQhNKH/yCOBq/MtZcK20HAZ7a9qqLJrbBaZsQwBWq9Ymx9wlxEGA4EImqK36I2SB09CMA== X-Received: by 2002:a25:5d07:: with SMTP id r7-v6mr1847970ybb.482.1521129226081; Thu, 15 Mar 2018 08:53:46 -0700 (PDT) Received: from localhost ([72.188.97.40]) by smtp.gmail.com with ESMTPSA id u128sm1898300ywb.62.2018.03.15.08.53.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Mar 2018 08:53:45 -0700 (PDT) From: William Breathitt Gray To: linus.walleij@linaro.org Cc: andy.shevchenko@gmail.com, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, William Breathitt Gray Subject: [PATCH v2 8/8] gpio: ws16c48: Implement get_multiple callback Date: Thu, 15 Mar 2018 11:53:39 -0400 Message-Id: <78fd4e6464713068ba9292ba8ef5d9227cdd294c.1521128287.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: References: Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The WinSystems WS16C48 device provides 48 lines of digital I/O accessed via six 8-bit ports. Since eight input lines are acquired on a single port input read, the WS16C48 GPIO driver may improve multiple input reads by utilizing a get_multiple callback. This patch implements the ws16c48_gpio_get_multiple function which serves as the respective get_multiple callback. Signed-off-by: William Breathitt Gray --- drivers/gpio/gpio-ws16c48.c | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/gpio/gpio-ws16c48.c b/drivers/gpio/gpio-ws16c48.c index 746648244bf3..9f2e7d0b48f9 100644 --- a/drivers/gpio/gpio-ws16c48.c +++ b/drivers/gpio/gpio-ws16c48.c @@ -129,6 +129,51 @@ static int ws16c48_gpio_get(struct gpio_chip *chip, unsigned offset) return !!(port_state & mask); } +static int ws16c48_gpio_get_multiple(struct gpio_chip *chip, + unsigned long *mask, unsigned long *bits) +{ + struct ws16c48_gpio *const ws16c48gpio = gpiochip_get_data(chip); + const unsigned int gpio_reg_size = 8; + size_t i; + const size_t num_ports = chip->ngpio / gpio_reg_size; + unsigned int bits_offset; + size_t word_index; + unsigned int word_offset; + unsigned long mask_word; + const unsigned long port_mask = GENMASK(gpio_reg_size, 0); + unsigned long port_state; + + /* clear bits array to a clean slate */ + bitmap_zero(bits, chip->ngpio); + + /* get bits are evaluated a gpio port register at a time */ + for (i = 0; i < num_ports; i++) { + /* gpio offset in bits array */ + bits_offset = i * gpio_reg_size; + + /* word index for bits array */ + word_index = BIT_WORD(bits_offset); + + /* gpio offset within current word of bits array */ + word_offset = bits_offset % BITS_PER_LONG; + + /* mask of get bits for current gpio within current word */ + word_mask = mask[word_index] & (port_mask << word_offset); + if (!word_mask) { + /* no get bits in this port so skip to next one */ + continue; + } + + /* read bits from current gpio port */ + port_state = inb(ws16c48gpio->base + i); + + /* store acquired bits at respective bits array offset */ + bits[word_index] |= port_state << word_offset; + } + + return 0; +} + static void ws16c48_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { struct ws16c48_gpio *const ws16c48gpio = gpiochip_get_data(chip); @@ -383,6 +428,7 @@ static int ws16c48_probe(struct device *dev, unsigned int id) ws16c48gpio->chip.direction_input = ws16c48_gpio_direction_input; ws16c48gpio->chip.direction_output = ws16c48_gpio_direction_output; ws16c48gpio->chip.get = ws16c48_gpio_get; + ws16c48gpio->chip.get_multiple = ws16c48_gpio_get_multiple; ws16c48gpio->chip.set = ws16c48_gpio_set; ws16c48gpio->chip.set_multiple = ws16c48_gpio_set_multiple; ws16c48gpio->base = base[id];