From patchwork Sat Apr 9 11:30:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 608362 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 3qhvJx0zQ7z9t6s for ; Sat, 9 Apr 2016 21:30:41 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b=VlVdljMg; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752817AbcDILaj (ORCPT ); Sat, 9 Apr 2016 07:30:39 -0400 Received: from mail-lf0-f45.google.com ([209.85.215.45]:36844 "EHLO mail-lf0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752721AbcDILaj (ORCPT ); Sat, 9 Apr 2016 07:30:39 -0400 Received: by mail-lf0-f45.google.com with SMTP id g184so105338059lfb.3 for ; Sat, 09 Apr 2016 04:30:38 -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; bh=BL735P00tz5kYb6GNq/I8SSMNsJd4cCSW2/QnJlulUI=; b=VlVdljMgUPMIb43di+Ne2axmcS2hVzXLftgeV3neh8bI5KwxpOKZcnk5P+34s+/nbX qJtnolljrZERzs7bN0dCfGd8PLjsauoPBVUAvknrqecYO0hEhjqKzK1F+VMhtWr/qz5J Qe18asu71GhOL1PdF6CQL+E2G/7liSAA9i3dU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=BL735P00tz5kYb6GNq/I8SSMNsJd4cCSW2/QnJlulUI=; b=OFS6O81VT06NU3kkzvK5UclzaZUq9Gcwt1MbIivJ/FKx5iZ+dp04fTCuUeAcZBNIW6 C2xkxco8BZ3/SoyNPZWHUazi/87JEAmgbiI8TaS2VsArjI5a0/C55t78CU10QNUPykNi cv1ecLGQCGpXdzRarBWFqRsQlFgFhPl+5c6MBAcDicd6AEH5s4bZ1KxMeqte5M3BcsdJ 2oA3YHCXgup+dlT+s9raFBLKDBaCOjtQN6QJFsZqmu4GKvtlai7Eo8aXz3nv3gzxzRBX +lGlqPGdyzVoRa3QF11qOBTpOIR1Gwoy7I2VsBVlKB8tXTgQshQ+sA/qhnk5kgtMMJxV QYfg== X-Gm-Message-State: AD7BkJJ4g9sVVxcl6ZoAoLAKP9n3XZMYpLUkdrZxLkGF4/LARUKq2+qKDmRU3skQrx/H+xwt X-Received: by 10.112.169.105 with SMTP id ad9mr5242050lbc.135.1460201437220; Sat, 09 Apr 2016 04:30:37 -0700 (PDT) Received: from localhost.localdomain.localdomain (c-927b71d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.123.146]) by smtp.gmail.com with ESMTPSA id i9sm2815062lfe.31.2016.04.09.04.30.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Apr 2016 04:30:36 -0700 (PDT) From: Linus Walleij To: linux-gpio@vger.kernel.org, Alexandre Courbot Cc: Linus Walleij , Wei Chen , Peter Rosin Subject: [PATCH] gpio: sx150x: use the new open drain callback Date: Sat, 9 Apr 2016 13:30:32 +0200 Message-Id: <1460201432-32652-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.4.3 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org One variant of the SX150X GPIO chip supports setting the pins in open drain mode. This is currently available to set from platform data, but completely unused in the kernel. Activate the new .set_single_ended() callback so users can set this up from e.g. device tree or board files using the new GPIO descriptors. As part of this, delete the platform data open drain setting method. Cc: Wei Chen Cc: Peter Rosin Signed-off-by: Linus Walleij --- drivers/gpio/gpio-sx150x.c | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/drivers/gpio/gpio-sx150x.c b/drivers/gpio/gpio-sx150x.c index d4501d5f8b8e..a177ebd921d5 100644 --- a/drivers/gpio/gpio-sx150x.c +++ b/drivers/gpio/gpio-sx150x.c @@ -105,13 +105,6 @@ struct sx150x_device_data { * bit at position n will enable the pull-down for the IO at * the corresponding offset. For chips with fewer than * 16 IO pins, high-end bits are ignored. - * @io_open_drain_ena: A bit-mask which enables-or disables open-drain - * operation for each IO line in the expander. Setting the - * bit at position n enables open-drain operation for - * the IO at the corresponding offset. Clearing the bit - * enables regular push-pull operation for that IO. - * For chips with fewer than 16 IO pins, high-end bits - * are ignored. * @io_polarity: A bit-mask which enables polarity inversion for each IO line * in the expander. Setting the bit at position n inverts * the polarity of that IO line, while clearing it results @@ -136,7 +129,6 @@ struct sx150x_platform_data { bool oscio_is_gpo; u16 io_pullup_ena; u16 io_pulldn_ena; - u16 io_open_drain_ena; u16 io_polarity; int irq_summary; unsigned irq_base; @@ -415,6 +407,32 @@ static void sx150x_gpio_set(struct gpio_chip *gc, unsigned offset, int val) mutex_unlock(&chip->lock); } +static int sx150x_gpio_set_single_ended(struct gpio_chip *gc, + unsigned offset, + enum single_ended_mode mode) +{ + struct sx150x_chip *chip = gpiochip_get_data(gc); + + /* On the SX160X 789 we can set open drain */ + if (chip->dev_cfg->model != SX150X_789) + return -ENOTSUPP; + + if (mode == LINE_MODE_PUSH_PULL) + return sx150x_write_cfg(chip, + offset, + 1, + chip->dev_cfg->pri.x789.reg_drain, + 0); + + if (mode == LINE_MODE_OPEN_DRAIN) + return sx150x_write_cfg(chip, + offset, + 1, + chip->dev_cfg->pri.x789.reg_drain, + 1); + return -ENOTSUPP; +} + static int sx150x_gpio_direction_input(struct gpio_chip *gc, unsigned offset) { struct sx150x_chip *chip = gpiochip_get_data(gc); @@ -569,6 +587,7 @@ static void sx150x_init_chip(struct sx150x_chip *chip, chip->gpio_chip.direction_output = sx150x_gpio_direction_output; chip->gpio_chip.get = sx150x_gpio_get; chip->gpio_chip.set = sx150x_gpio_set; + chip->gpio_chip.set_single_ended = sx150x_gpio_set_single_ended; chip->gpio_chip.base = pdata->gpio_base; chip->gpio_chip.can_sleep = true; chip->gpio_chip.ngpio = chip->dev_cfg->ngpios; @@ -658,12 +677,6 @@ static int sx150x_init_hw(struct sx150x_chip *chip, if (chip->dev_cfg->model == SX150X_789) { err = sx150x_init_io(chip, - chip->dev_cfg->pri.x789.reg_drain, - pdata->io_open_drain_ena); - if (err < 0) - return err; - - err = sx150x_init_io(chip, chip->dev_cfg->pri.x789.reg_polarity, pdata->io_polarity); if (err < 0)