From patchwork Sun Apr 10 13:12:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 65437 Delivered-To: patch@linaro.org Received: by 10.112.43.237 with SMTP id z13csp976842lbl; Sun, 10 Apr 2016 06:12:28 -0700 (PDT) X-Received: by 10.50.20.40 with SMTP id k8mr13815173ige.9.1460293948709; Sun, 10 Apr 2016 06:12:28 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 10si11438287igt.78.2016.04.10.06.12.28; Sun, 10 Apr 2016 06:12:28 -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 S1751539AbcDJNM2 (ORCPT + 4 others); Sun, 10 Apr 2016 09:12:28 -0400 Received: from mail-lf0-f47.google.com ([209.85.215.47]:33062 "EHLO mail-lf0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751351AbcDJNM1 (ORCPT ); Sun, 10 Apr 2016 09:12:27 -0400 Received: by mail-lf0-f47.google.com with SMTP id e190so124034475lfe.0 for ; Sun, 10 Apr 2016 06:12:26 -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=kJqrmcQYHaxLhACQt0a5BYdEP6ccgt6O1JqFe95lsMw=; b=Wxl0Z6hBzZL0ZiR2pmrOAf5hWo+hskGnnpTpCkdNUE4K7T+UOjtl/zTktwVGBzJ4IK LpcPQf3GQ5wHxOZAK8RivXMCELf7st3u9dLsuPoou+jErkWf/f49Z8WHq0zih2AcdO9t FXa+4+qqWN/2vAeo6SunswSSUHaaB1IlJh1n8= 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=kJqrmcQYHaxLhACQt0a5BYdEP6ccgt6O1JqFe95lsMw=; b=OuxuVcGpL7zYcZNFxc5WxJndvp8dQ6OlHGak8+ujGjCLwB7odAZDMExpik25THXg5h /YHRxAGOAJna/zq91LEgxEAbM+rYiPXQZiidU/ItgbpwGVW0+0FghI9jNrBMuBOt/7mF ju6r0Gv4P+fIJoGTWPt8KJczEf/x/I9YTPvKg25fPQgYg9IK4PEPm9kJtTHidAeIuykC sAfwdHx4U2j2tELszu6nw1aDGG0YM8BgVtWFpyx6QD2Zod/U9HuyRmSNkJ23zVWWsjtL 1HWfknG8/OF2/pRpRmQB/wczDlCwDQYNfaSw9CsOIB1ojfRCSfIfAmWTa5OdjSg15Xjx 3beA== X-Gm-Message-State: AD7BkJLKPRD3lsufJfAq+0sQuBhWVMwd1TbaOREGw4tlUF8FNeufrYyhgaUAWHRfhm1cXfeU X-Received: by 10.112.51.48 with SMTP id h16mr6759842lbo.7.1460293945517; Sun, 10 Apr 2016 06:12:25 -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 j39sm3676182lfi.9.2016.04.10.06.12.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Apr 2016 06:12:24 -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 1/2] gpio: wm831x: use the new open drain callback Date: Sun, 10 Apr 2016 15:12:19 +0200 Message-Id: <1460293939-14181-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 WM831x 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 --- drivers/gpio/gpio-wm831x.c | 22 +++++++++++++++++++++- 1 file changed, 21 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-wm831x.c b/drivers/gpio/gpio-wm831x.c index 18cb0f534b91..c16c6fc3683c 100644 --- a/drivers/gpio/gpio-wm831x.c +++ b/drivers/gpio/gpio-wm831x.c @@ -132,6 +132,25 @@ static int wm831x_gpio_set_debounce(struct gpio_chip *chip, unsigned offset, return wm831x_set_bits(wm831x, reg, WM831X_GPN_FN_MASK, fn); } +static int wm831x_set_single_ended(struct gpio_chip *chip, + unsigned int offset, + enum single_ended_mode mode) +{ + struct wm831x_gpio *wm831x_gpio = gpiochip_get_data(chip); + struct wm831x *wm831x = wm831x_gpio->wm831x; + int reg = WM831X_GPIO1_CONTROL + offset; + + if (mode == LINE_MODE_OPEN_DRAIN) + return wm831x_set_bits(wm831x, reg, + WM831X_GPN_OD_MASK, WM831X_GPN_OD); + + if (mode == LINE_MODE_PUSH_PULL) + return wm831x_set_bits(wm831x, reg, + WM831X_GPN_OD_MASK, 0); + + return -ENOTSUPP; +} + #ifdef CONFIG_DEBUG_FS static void wm831x_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) { @@ -216,7 +235,7 @@ static void wm831x_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) pull, powerdomain, reg & WM831X_GPN_POL ? "" : " inverted", - reg & WM831X_GPN_OD ? "open-drain" : "CMOS", + reg & WM831X_GPN_OD ? "open-drain" : "push-pull", tristated ? " tristated" : "", reg); } @@ -234,6 +253,7 @@ static struct gpio_chip template_chip = { .set = wm831x_gpio_set, .to_irq = wm831x_gpio_to_irq, .set_debounce = wm831x_gpio_set_debounce, + .set_single_ended = wm831x_set_single_ended, .dbg_show = wm831x_gpio_dbg_show, .can_sleep = true, };