From patchwork Wed Jul 18 23:57:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10533491 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BFB006053F for ; Thu, 19 Jul 2018 00:00:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC2AA29942 for ; Thu, 19 Jul 2018 00:00:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D3E02995D; Thu, 19 Jul 2018 00:00:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 32A7429942 for ; Thu, 19 Jul 2018 00:00:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=3e9tvb36QAZU8E5zkBlH4d9X4TIly/GxWIC5w1NgxtE=; b=oft1avBDNvUPGpY/Oo9GvzOnvp 9IaEKlm67QAhYMExztpqQLn7dXkHSrbaMLbkEUnV3wLGJ+lyHtH4+4MZjS6q9sT0vk0xsd44PyWJ/ lTa7D8qUUOWxh4odYMAvIMxKOIgf5da/mUwAX8W8tltiTMsVoYApWgzR5YDYYhCBRlR8TA9cY1ygt ZV0FVJftScmQ6uSQoZG3/CYbe5z2tPZcnkRORcId7Mjn1cMRVwU2gSjF45uAr1VV1mLhvIVAWfXYx 85T8uUv3WaEcpdt8jhLAOet1gUkbaKGZPk6UOjHahd0gC/y9WXpCDdXi8g1NEvbb/zX98m7pd8O2F PBlQcCPQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ffwMs-0001QR-Gq; Thu, 19 Jul 2018 00:00:26 +0000 Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ffwJi-0005mx-Ce; Wed, 18 Jul 2018 23:57:16 +0000 Received: by mail-lf0-x241.google.com with SMTP id u14-v6so4705590lfu.0; Wed, 18 Jul 2018 16:56:59 -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=CE/jxx2sQAbPpsFa3TmZtxhtrPIRLZ2UctIF4wmgTIo=; b=idMPapN1PMb2v3kaVFZwajOJPP3xHfJcUb8WU3xBxgb+nbB6xrDNlzN8y8Px1lWSJx +xpnKFkJLID0cyzWLQg0j5n/JSDIWy5MCZmWgCyAQm5qJpgzRAG/gcjhFzv76h/yawVY er4SSvjYM9V2AQTlxv6VajL6TJRPFNnG7L0yAoriRX1kUN/8o467HD9P+4E1MLFKrtZP +UfzF2TUcK50yK/peWuK9bui82ZoHG95gZRxlpmuvwtRb5ATKnahrT1EUqB3X5WBWlqD o48nQVH1bfOCMP9vN6+RISFx8mxbjnQG4HhE2Lzkwm4mBVFxhK2E81qc8XCDJNEnEEGo 3qVg== 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=CE/jxx2sQAbPpsFa3TmZtxhtrPIRLZ2UctIF4wmgTIo=; b=lZuUoPDAjO4CgRwV42vlmtNw3dl/k85Rqs86l477NUGp9RgJpF/lWcfnfIRtwW2HyO Iv7Kr+re8gAbSB6ZxtLHlVPyNpXvu9qKW+2CMRQLDC99IOHryJSJtexCDUHnrjLKLJbX KvMqAPIjI3H6B3M2jCIPGDyodr42RpYqGLl0TeFcCzZGh/PAu/KiZ0gZWKP17iWX89oD Krefdg/5Q+bhndWHlRScnthSWDrDDgWXXmIlbBdxgWuJg/KPvAd7zNQot3Fv52C7KHdL 65oQNMiAmwRvxa+wEmZzpoaU5ts1WXDhvqRlEmlMTSaLiZb6pSBfoQYcOLvN3dzN4hS3 lsZQ== X-Gm-Message-State: AOUpUlFWjCndNULw4rVpEI2S+qP+zEeDmMBoG0fngwXQR2oT5IEVzdmj vmBOza3937MNMb+KaO7vfVM= X-Google-Smtp-Source: AAOMgpcKNid2fOSMPG4hIn05+moSynVjPs/1EOVnUIR+ZtsKh2JJ2UvoeBTuHTgJftkgB41Ewr2dEQ== X-Received: by 2002:a19:4e06:: with SMTP id c6-v6mr4970804lfb.30.1531958218420; Wed, 18 Jul 2018 16:56:58 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id h7-v6sm826584ljk.27.2018.07.18.16.56.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jul 2018 16:56:57 -0700 (PDT) From: Janusz Krzysztofik To: Boris Brezillon , Miquel Raynal Subject: [RFC PATCH 6/8] gpio: omap: Add get/set_multiple() callbacks Date: Thu, 19 Jul 2018 01:57:08 +0200 Message-Id: <20180718235710.18242-7-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180718235710.18242-1-jmkrzyszt@gmail.com> References: <20180718235710.18242-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180718_165710_927428_959AB6A9 X-CRM114-Status: GOOD ( 15.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Grygorii Strashko , Kevin Hilman , Tony Lindgren , Richard Weinberger , Linus Walleij , Aaro Koskinen , Artem Bityutskiy , linux-kernel@vger.kernel.org, Marek Vasut , linux-omap@vger.kernel.org, Janusz Krzysztofik , linux-mtd@lists.infradead.org, linux-gpio@vger.kernel.org, Santosh Shilimkar , Brian Norris , David Woodhouse , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This should make applications utilizing whole banks work faster. Signed-off-by: Janusz Krzysztofik Acked-by: Grygorii Strashko --- drivers/gpio/gpio-omap.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 86 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index d1afedf4dcbf..e81008678a38 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c @@ -77,6 +77,8 @@ struct gpio_bank { bool workaround_enabled; void (*set_dataout)(struct gpio_bank *bank, unsigned gpio, int enable); + void (*set_dataout_multiple)(struct gpio_bank *bank, + unsigned long *mask, unsigned long *bits); int (*get_context_loss_count)(struct device *dev); struct omap_gpio_reg_offs *regs; @@ -161,6 +163,51 @@ static int omap_get_gpio_dataout(struct gpio_bank *bank, int offset) return (readl_relaxed(reg) & (BIT(offset))) != 0; } +/* set multiple data out values using dedicate set/clear register */ +static void omap_set_gpio_dataout_reg_multiple(struct gpio_bank *bank, + unsigned long *mask, + unsigned long *bits) +{ + void __iomem *reg = bank->base; + u32 l; + + l = *bits & *mask; + writel_relaxed(l, reg + bank->regs->set_dataout); + bank->context.dataout |= l; + + l = ~*bits & *mask; + writel_relaxed(l, reg + bank->regs->clr_dataout); + bank->context.dataout &= ~l; +} + +/* set multiple data out values using mask register */ +static void omap_set_gpio_dataout_mask_multiple(struct gpio_bank *bank, + unsigned long *mask, + unsigned long *bits) +{ + void __iomem *reg = bank->base + bank->regs->dataout; + u32 l = (readl_relaxed(reg) & ~*mask) | (*bits & *mask); + + writel_relaxed(l, reg); + bank->context.dataout = l; +} + +static unsigned long omap_get_gpio_datain_multiple(struct gpio_bank *bank, + unsigned long *mask) +{ + void __iomem *reg = bank->base + bank->regs->datain; + + return readl_relaxed(reg) & *mask; +} + +static unsigned long omap_get_gpio_dataout_multiple(struct gpio_bank *bank, + unsigned long *mask) +{ + void __iomem *reg = bank->base + bank->regs->dataout; + + return readl_relaxed(reg) & *mask; +} + static inline void omap_gpio_rmw(void __iomem *base, u32 reg, u32 mask, bool set) { int l = readl_relaxed(base + reg); @@ -968,6 +1015,26 @@ static int omap_gpio_output(struct gpio_chip *chip, unsigned offset, int value) return 0; } +static int omap_gpio_get_multiple(struct gpio_chip *chip, unsigned long *mask, + unsigned long *bits) +{ + struct gpio_bank *bank = gpiochip_get_data(chip); + void __iomem *reg = bank->base + bank->regs->direction; + unsigned long in = readl_relaxed(reg), l; + + *bits = 0; + + l = in & *mask; + if (l) + *bits |= omap_get_gpio_datain_multiple(bank, &l); + + l = ~in & *mask; + if (l) + *bits |= omap_get_gpio_dataout_multiple(bank, &l); + + return 0; +} + static int omap_gpio_debounce(struct gpio_chip *chip, unsigned offset, unsigned debounce) { @@ -1012,6 +1079,17 @@ static void omap_gpio_set(struct gpio_chip *chip, unsigned offset, int value) raw_spin_unlock_irqrestore(&bank->lock, flags); } +static void omap_gpio_set_multiple(struct gpio_chip *chip, unsigned long *mask, + unsigned long *bits) +{ + struct gpio_bank *bank = gpiochip_get_data(chip); + unsigned long flags; + + raw_spin_lock_irqsave(&bank->lock, flags); + bank->set_dataout_multiple(bank, mask, bits); + raw_spin_unlock_irqrestore(&bank->lock, flags); +} + /*---------------------------------------------------------------------*/ static void omap_gpio_show_rev(struct gpio_bank *bank) @@ -1073,9 +1151,11 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc) bank->chip.get_direction = omap_gpio_get_direction; bank->chip.direction_input = omap_gpio_input; bank->chip.get = omap_gpio_get; + bank->chip.get_multiple = omap_gpio_get_multiple; bank->chip.direction_output = omap_gpio_output; bank->chip.set_config = omap_gpio_set_config; bank->chip.set = omap_gpio_set; + bank->chip.set_multiple = omap_gpio_set_multiple; if (bank->is_mpuio) { bank->chip.label = "mpuio"; if (bank->regs->wkup_en) @@ -1209,10 +1289,14 @@ static int omap_gpio_probe(struct platform_device *pdev) pdata->get_context_loss_count; } - if (bank->regs->set_dataout && bank->regs->clr_dataout) + if (bank->regs->set_dataout && bank->regs->clr_dataout) { bank->set_dataout = omap_set_gpio_dataout_reg; - else + bank->set_dataout_multiple = omap_set_gpio_dataout_reg_multiple; + } else { bank->set_dataout = omap_set_gpio_dataout_mask; + bank->set_dataout_multiple = + omap_set_gpio_dataout_mask_multiple; + } raw_spin_lock_init(&bank->lock); raw_spin_lock_init(&bank->wa_lock);