From patchwork Thu Apr 2 09:43:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 457577 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 7AB39140083 for ; Thu, 2 Apr 2015 20:43:39 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750745AbbDBJnj (ORCPT ); Thu, 2 Apr 2015 05:43:39 -0400 Received: from mout.web.de ([212.227.17.11]:58439 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750711AbbDBJni (ORCPT ); Thu, 2 Apr 2015 05:43:38 -0400 Received: from kongar.lan.local ([185.44.151.123]) by smtp.web.de (mrweb102) with ESMTPSA (Nemesis) id 0MBkLb-1YlbkX45kF-00Ajgs; Thu, 02 Apr 2015 11:43:35 +0200 From: Alexander Stein To: Jean-Christophe Plagniol-Villard , Linus Walleij Cc: Alexander Stein , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, Ludovic Desroches Subject: [PATCH v2 1/1] pinctrl: at91: Add set_multiple GPIO chip feature Date: Thu, 2 Apr 2015 11:43:18 +0200 Message-Id: <1427967798-6962-1-git-send-email-alexanders83@web.de> X-Mailer: git-send-email 2.3.4 X-Provags-ID: V03:K0:rb6hUCvDfPsEOsTxFwNntL7INW+jwoYlWAs0mmL+GODybdA+Vz+ G/rBH1tqVLemGBVOWiP7UO7ltXhuTRNgxSMq3KEYiYZszOSdjPDhn/mbkl3lZoeT2tkmsns ajQIoMAb+Qp3b5fvMFaVzjj/EltlhJy/pXJi0IGseeBv2bRyd/gowfs1YqPUoaPOWWHS+Ya x2JHTVlG19fXRkJeqQORw== X-UI-Out-Filterresults: notjunk:1; Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This adds the callback for set_multiple. As this controller has a separate set and clear register, we can't write directly to PIO_ODSR as this would required a cached variable and would race with at91_gpio_set. So build masks for the PIO_SODR and PIO_CODR registers and write them together. Signed-off-by: Alexander Stein --- Changes in v2: * Greatly simplyfied the implementation: Generate the set- and clear-mask directly from 'mask' and 'bits' I skipped the 'Acked-by: Ludovic Desroches ' due to the new implementation. drivers/pinctrl/pinctrl-at91.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index a4814066ea08..3a7b008a9a4e 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c @@ -1330,6 +1330,18 @@ static void at91_gpio_set(struct gpio_chip *chip, unsigned offset, writel_relaxed(mask, pio + (val ? PIO_SODR : PIO_CODR)); } +static void at91_gpio_set_multiple(struct gpio_chip *chip, + unsigned long *mask, unsigned long *bits) +{ + struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); + void __iomem *pio = at91_gpio->regbase; + uint32_t set_mask = *mask & *bits; + uint32_t clear_mask = *mask & ~(*bits); + + writel_relaxed(set_mask, pio + PIO_SODR); + writel_relaxed(clear_mask, pio + PIO_CODR); +} + static int at91_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int val) { @@ -1689,6 +1701,7 @@ static struct gpio_chip at91_gpio_template = { .get = at91_gpio_get, .direction_output = at91_gpio_direction_output, .set = at91_gpio_set, + .set_multiple = at91_gpio_set_multiple, .dbg_show = at91_gpio_dbg_show, .can_sleep = false, .ngpio = MAX_NB_GPIO_PER_BANK,