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: 65429 Delivered-To: patch@linaro.org Received: by 10.112.43.237 with SMTP id z13csp527255lbl; Sat, 9 Apr 2016 04:30:40 -0700 (PDT) X-Received: by 10.98.74.200 with SMTP id c69mr19052191pfj.129.1460201440581; Sat, 09 Apr 2016 04:30:40 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q76si6551183pfa.60.2016.04.09.04.30.40; Sat, 09 Apr 2016 04:30:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752817AbcDILaj (ORCPT + 4 others); 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(-) -- 2.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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)