Received: by 10.213.65.68 with SMTP id h4csp286611imn; Mon, 12 Mar 2018 13:52:07 -0700 (PDT) X-Google-Smtp-Source: AG47ELsR70p8vgybG08JkqPX6UgHa1jna1WBajVgcLTxA7W97AThCzRC7AKvmsnZrh7EfWWd8EjV X-Received: by 2002:a17:902:57c1:: with SMTP id g1-v6mr9455599plj.381.1520887927829; Mon, 12 Mar 2018 13:52:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520887927; cv=none; d=google.com; s=arc-20160816; b=ZNAUU30s1S/hQlyV4LyIBUZjIAJ1zXy00RGyrJaXsZp39Y228Yf7xvl/KBTaV9xSN9 CcBku0BRnDg6SC90viKVIWnrR7MeGsNSBTVKY3EbmBXyXjWnrstv527a+sgNnIVvAPsh zaFAZOnMoXgUhDQMhraiH1LsuqXRk0xTmQr9p7uqdZh43zR4KRR3vGaQ25m9u73zJI2U MIML3uGNERNFWgF21F91giXEbjtjkKvmVcGZ4K3VGPbznbSmKGwEMDjEKHVTMTTAT70l 85aHh8Mkl+PnMMwR2Gd4eUQuB0y8N05sCPe2A0UHqj1DTC5ulEhD+BSgHaeyfhSlra6o svZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=kLDV0HGYgPPJceXoBrDErFSjfMCg52cjK/Oh29azbnY=; b=t22SMhmXUJQFz7GRfs4bGvImWMqyd6XVo57qkxRmx7xOb6rlFtOyava8+ihpsBYLdn 5AgpKYn2lu0usMVh9KCL1rHifZRIKD+IFabJAb3j4AJpZ2TNDN4C2zLK05UWFCMLZ5Uu Pw8AqNl7Wzue7RQjgi2ndf5yKIoQjHIJV5deyyLs1oIJ8pbTyt1/TUk/BEgty4OLOSfM s+o2DPCoXIyJriLgxgijCipH8YMmPJDfrbpJb1wuLMbKVS6UfcU/OpPddwBAFAXINsES e9coCpN5TfWvhCEz1KzFJctbmOUsyua3uplB4XPdnp/yT0fj4FMJuimf6jJMYJTc75oC rOrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=f2TjsVWA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c4si5504166pgt.733.2018.03.12.13.51.53; Mon, 12 Mar 2018 13:52:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=f2TjsVWA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932572AbeCLUub (ORCPT + 99 others); Mon, 12 Mar 2018 16:50:31 -0400 Received: from mail-yw0-f196.google.com ([209.85.161.196]:41450 "EHLO mail-yw0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932525AbeCLUu2 (ORCPT ); Mon, 12 Mar 2018 16:50:28 -0400 Received: by mail-yw0-f196.google.com with SMTP id w12so6393696ywa.8; Mon, 12 Mar 2018 13:50:28 -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=kLDV0HGYgPPJceXoBrDErFSjfMCg52cjK/Oh29azbnY=; b=f2TjsVWAWLp4/v5DsuinWt7UwURkbKV2aklYcdTP7T6zY7oYMZyHr6hyhFsYCk6eGQ PnRk1zTG/+NiJIm1UIj/aVoOIxidcfTO9xE096pQ6MgZTlDTofJ9PeChdK5ocmMFBZLW hXxhnALMtxyvAp7M6vPjHGWfCC2+C/BIOhhMiP+IyOzsr1tnHphBmjV+OXiUmHE3LeAA lfNidc413iqw/u0fQCY05N130puhkV5f7iCE2FQiUtx8PPC+syTEBSKmYSPfrPTrkAWc tmc2S0RAdoB6L99ASPSClyktEhHMhFuaxj2cBE70PMhYjDy+y3C3R9WLRnB+YlEhOCr6 mowg== 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=kLDV0HGYgPPJceXoBrDErFSjfMCg52cjK/Oh29azbnY=; b=TTHkxY1ck+rOFN4kIC11o+yQGAy9TPyz5M/tHQIyvtvPMlUgF/7kGagHTDM5bYLwm5 PZdecAl+46ews4h47Byc88dVNrxzHxJ46AaW/tCfWFZ1Psee2hInTI7QnzJuXXq4h+1X YT0WvlZ7Lo4dtkRiYyTGqU1ZiV+HFyWnLewYfMRF5C9/vz25Tbi8QWjuyR4L+X9eQlAJ CFJQA7X6BLrvKAXvDB9xfuMfg9nKrL38bTEJfpmVNJQHpwzzF5y0ptePK6Tx+ZAJ6vWt vDZTsJJLGr/1SOi9ivcZduFBQIryaVDHbWC/V+Y6todLnXiYLzXnbtaGXOL6tj9Qf9U7 gsdQ== X-Gm-Message-State: AElRT7HfXH+TaVAUHzdSlVq/ahDUb5qwvd44s4z8eGAPFipfpP2jSV2n zeg3eC8fUXdzP1yjaoroSBY= X-Received: by 2002:a25:84c5:: with SMTP id x5-v6mr3413111ybm.430.1520887828067; Mon, 12 Mar 2018 13:50:28 -0700 (PDT) Received: from localhost ([72.188.97.40]) by smtp.gmail.com with ESMTPSA id l15sm3364437ywk.44.2018.03.12.13.50.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Mar 2018 13:50:27 -0700 (PDT) From: William Breathitt Gray To: linus.walleij@linaro.org Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, William Breathitt Gray Subject: [PATCH 7/8] gpio: gpio-mm: Implement get_multiple callback Date: Mon, 12 Mar 2018 16:50:22 -0400 Message-Id: <909f0d3dac7a9f24cfd92f05f4d1e84f569162b1.1520886945.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/gpio/gpio-gpio-mm.c b/drivers/gpio/gpio-gpio-mm.c index 11ade5b288f8..5bacfa1f2c02 100644 --- a/drivers/gpio/gpio-gpio-mm.c +++ b/drivers/gpio/gpio-gpio-mm.c @@ -171,6 +171,46 @@ 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); + unsigned int i; + const unsigned int gpio_reg_size = 8; + unsigned int bit_word_offset; + unsigned int bits_mask; + const unsigned long reg_mask = GENMASK(gpio_reg_size, 0); + unsigned int port; + unsigned int in_port; + unsigned long port_state; + + /* clear bits array to a clean slate */ + for (i = 0; i < chip->ngpio; i += BITS_PER_LONG) + bits[i / BITS_PER_LONG] = 0; + + /* get bits are evaluated a gpio register size at a time */ + for (i = 0; i < chip->ngpio; i += gpio_reg_size) { + bit_word_offset = i % BITS_PER_LONG; + bits_mask = mask[BIT_WORD(i)] & (reg_mask << bit_word_offset); + if (!bits_mask) { + /* no get bits in this register so skip to next one */ + continue; + } + + /* compute input port offset */ + port = i / gpio_reg_size; + in_port = (port > 2) ? port + 1 : port; + + /* get input bits */ + port_state = inb(gpiommgpio->base + in_port); + + /* store acquired bits */ + bits[BIT_WORD(i)] |= port_state << bit_word_offset; + } + + return 0; +} + static void gpiomm_gpio_set(struct gpio_chip *chip, unsigned int offset, int value) { @@ -268,6 +308,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]; -- 2.16.2