From patchwork Tue Apr 12 07:29:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 65589 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp1768339qge; Tue, 12 Apr 2016 00:29:56 -0700 (PDT) X-Received: by 10.66.124.226 with SMTP id ml2mr2607272pab.90.1460446196184; Tue, 12 Apr 2016 00:29:56 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 78si8443079pfq.236.2016.04.12.00.29.55; Tue, 12 Apr 2016 00:29:56 -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 S1756017AbcDLH3z (ORCPT + 4 others); Tue, 12 Apr 2016 03:29:55 -0400 Received: from mail-lf0-f48.google.com ([209.85.215.48]:33746 "EHLO mail-lf0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755917AbcDLH3z (ORCPT ); Tue, 12 Apr 2016 03:29:55 -0400 Received: by mail-lf0-f48.google.com with SMTP id e190so12927944lfe.0 for ; Tue, 12 Apr 2016 00:29:54 -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=OXnMjKmB207zXRIDFMPL9VaeQyZYoK73/6r7kGgRmVU=; b=Gu5umJyhVX5oS+FITRNmir9IjBnCHvrClNFPZCQJlFr5h6U3ph/xmVUMw3uRCaUIzD lBjTpEsC5GJrEpJORYeCMYwaj3Dg/Yly9MQya7n8x+PjqOmKMzXR5T8mlhO16XUlE5s9 aKsNPOGFhTOFqKBzaQjpMWgQiRIuNJgFdLJ/w= 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=OXnMjKmB207zXRIDFMPL9VaeQyZYoK73/6r7kGgRmVU=; b=YxnhVsoW1+/RAKhehRJVjpmXOncYVyJlMm6larVSd9jeclnvEYKVvqbXUv+8UEsWPs p1sD8rgSRd6PT6m6b5qU/FnELBulaAZDm9zpJGMNyuYMx3Bpx3Ujqs7ZB3NaffnfVmhZ 45N7hHCo9Vh2wtcOCwFWZmi1c3Gt9w4wsAERTO76dUMHY2efMc0GWqc0g2/qlpxWD+pj jTNbJspblcJOzYxckA6Nc3+3z9jMTUuCApxFcO1KyONR9XDMmbUx+iNDN0OU7hiWK21d jjmj6RdNAJjNBiTjXCTaiSvVnetnxPcasPqqCHd7YVvPRO7CjcXAzh5wNh1M4qOswzA9 pwaQ== X-Gm-Message-State: AOPr4FVwFrLQUIA6Ee7OflkTVgtfblS2wBuQcB1kVFmPwv8zQvRb7cehSAAhCwD87w8e4Um7 X-Received: by 10.25.148.14 with SMTP id w14mr762364lfd.150.1460446193529; Tue, 12 Apr 2016 00:29:53 -0700 (PDT) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r130sm4527956lfe.6.2016.04.12.00.29.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Apr 2016 00:29:52 -0700 (PDT) From: Linus Walleij To: linux-gpio@vger.kernel.org, Alexandre Courbot Cc: Linus Walleij , patches@opensource.wolfsonmicro.com, Mark Brown , Charles Keepax Subject: [PATCH 2/2] gpio: wm8994: use the new open drain callback Date: Tue, 12 Apr 2016 09:29:49 +0200 Message-Id: <1460446189-16444-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 The WM8994 GPIOs clearly have a dedicated open drain control register. Implement support for controlling this from GPIO descriptor tables or other hardware descriptions such as device tree by implementing the .set_single_ended() callback. Before this patch, lines requesting open drain will just be switched to input mode by the framework, thus emulating open drain. But the hardware can do the real thing, so let's support that. As part of this, rename the debugfs string for output mode from "CMOS" to "push-pull" because it is the term used in the framework to signify a tomem-pole CMOS output. Cc: patches@opensource.wolfsonmicro.com Cc: Mark Brown Cc: Charles Keepax Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Use a switch() statement rather than if-constructions --- drivers/gpio/gpio-wm8994.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) -- 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-wm8994.c b/drivers/gpio/gpio-wm8994.c index b089df99a0d0..744af388c949 100644 --- a/drivers/gpio/gpio-wm8994.c +++ b/drivers/gpio/gpio-wm8994.c @@ -103,6 +103,28 @@ static void wm8994_gpio_set(struct gpio_chip *chip, unsigned offset, int value) wm8994_set_bits(wm8994, WM8994_GPIO_1 + offset, WM8994_GPN_LVL, value); } +static int wm8994_gpio_set_single_ended(struct gpio_chip *chip, + unsigned int offset, + enum single_ended_mode mode) +{ + struct wm8994_gpio *wm8994_gpio = gpiochip_get_data(chip); + struct wm8994 *wm8994 = wm8994_gpio->wm8994; + + switch (mode) { + case LINE_MODE_OPEN_DRAIN: + return wm8994_set_bits(wm8994, WM8994_GPIO_1 + offset, + WM8994_GPN_OP_CFG_MASK, + WM8994_GPN_OP_CFG); + case LINE_MODE_PUSH_PULL: + return wm8994_set_bits(wm8994, WM8994_GPIO_1 + offset, + WM8994_GPN_OP_CFG_MASK, 0); + default: + break; + } + + return -ENOTSUPP; +} + static int wm8994_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { struct wm8994_gpio *wm8994_gpio = gpiochip_get_data(chip); @@ -217,7 +239,7 @@ static void wm8994_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) if (reg & WM8994_GPN_OP_CFG) seq_printf(s, "open drain "); else - seq_printf(s, "CMOS "); + seq_printf(s, "push-pull "); seq_printf(s, "%s (%x)\n", wm8994_gpio_fn(reg & WM8994_GPN_FN_MASK), reg); @@ -235,6 +257,7 @@ static struct gpio_chip template_chip = { .get = wm8994_gpio_get, .direction_output = wm8994_gpio_direction_out, .set = wm8994_gpio_set, + .set_single_ended = wm8994_gpio_set_single_ended, .to_irq = wm8994_gpio_to_irq, .dbg_show = wm8994_gpio_dbg_show, .can_sleep = true,