From patchwork Fri Apr 8 12:16:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 65396 Delivered-To: patch@linaro.org Received: by 10.112.43.237 with SMTP id z13csp32899lbl; Fri, 8 Apr 2016 05:16:43 -0700 (PDT) X-Received: by 10.98.14.207 with SMTP id 76mr12335945pfo.1.1460117803682; Fri, 08 Apr 2016 05:16:43 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rk14si648995pab.187.2016.04.08.05.16.43; Fri, 08 Apr 2016 05:16:43 -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 S1753147AbcDHMQm (ORCPT + 4 others); Fri, 8 Apr 2016 08:16:42 -0400 Received: from mail-lb0-f180.google.com ([209.85.217.180]:33137 "EHLO mail-lb0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753118AbcDHMQl (ORCPT ); Fri, 8 Apr 2016 08:16:41 -0400 Received: by mail-lb0-f180.google.com with SMTP id u8so68190042lbk.0 for ; Fri, 08 Apr 2016 05:16:40 -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=drJrDvBGmlobTJA//1fS+Y5wxfDjIIoc3/uwQtLwZcc=; b=NX8IJ7DdYFY1vFj+k+bpwRSDaCngfRbCxZDuF5gQP5n17nMo5MqJzT+fcFVZQJwotx sSi9B4kOHkV5H3j+l4ZAzxSYEiaJgHfq6HI2iRcsrCahJAgGB+9bG9IdUNWc0vY1z59V /tfvrkgwcZfiFAZnXyxKMJTZ2VZu06JmG4LFc= 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=drJrDvBGmlobTJA//1fS+Y5wxfDjIIoc3/uwQtLwZcc=; b=jlAb0WTjtFMBuiTW79HiKvGVA8Fpe0FRK1UUOSHVxOinPhUp0YRbABOQ8md6t+dRFt YOxxlDtKyBc9iUpztBxJLrubuOKe0nrmchri+22d9gRZV5jC1mpM1AboMuzQLuaZ8Xrb UUDSUoj8hh1JzlTeXZDY8/cYTeF5NQCCJWjRw5dP+O6q2Q9YUbGnsZwjONksKHCxNc1M zj5Ld3KcpYD4Xp+CTZL6smwL+4GpSEvhNq5+rmuNr+tQjioeXVxHvR6n9mF0Vvznl4h0 vj7mGUMixCLCwG/xfzGgVSmXoGdlmSaShsUsIf2Ak1ZiayeqyaKRJeGkd2Vnifv8vT71 EVvA== X-Gm-Message-State: AD7BkJI0XxBk+fYmrTmQ7K7xf0c6kgQrQkyJ9tfjZLC7M4qYK3j/WN5Uj6LSCoWwgXTvrvxT X-Received: by 10.112.67.1 with SMTP id j1mr2852228lbt.103.1460117799910; Fri, 08 Apr 2016 05:16:39 -0700 (PDT) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id zi6sm1972501lbb.5.2016.04.08.05.16.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Apr 2016 05:16:39 -0700 (PDT) From: Linus Walleij To: linux-gpio@vger.kernel.org, Alexandre Courbot Cc: Linus Walleij , Nicolas Saenz Julienne Subject: [PATCH] gpio: tps65218: use the new open drain callback Date: Fri, 8 Apr 2016 14:16:28 +0200 Message-Id: <1460117788-3636-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 TPS65218 supports open drain mode on its three pins, with one of them configurable also as push-pull. Use the new .set_single_ended() callback to set this up properly from the core, so the core actually see it can drive the pin(s) as open drain, and does not attempt to emulate open drain by switching the pin to an input. Cc: Nicolas Saenz Julienne Signed-off-by: Linus Walleij --- drivers/gpio/gpio-tps65218.c | 45 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 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-tps65218.c b/drivers/gpio/gpio-tps65218.c index 313c0e484607..0eaeac8de9de 100644 --- a/drivers/gpio/gpio-tps65218.c +++ b/drivers/gpio/gpio-tps65218.c @@ -101,16 +101,6 @@ static int tps65218_gpio_request(struct gpio_chip *gc, unsigned offset) break; case 1: - /* GP02 is push-pull by default, can be set as open drain. */ - if (gpiochip_line_is_open_drain(gc, offset)) { - ret = tps65218_clear_bits(tps65218, - TPS65218_REG_CONFIG1, - TPS65218_CONFIG1_GPO2_BUF, - TPS65218_PROTECT_L1); - if (ret) - return ret; - } - /* Setup GPO2 */ ret = tps65218_clear_bits(tps65218, TPS65218_REG_CONFIG1, TPS65218_CONFIG1_IO1_SEL, @@ -148,6 +138,40 @@ static int tps65218_gpio_request(struct gpio_chip *gc, unsigned offset) return 0; } +static int tps65218_gpio_set_single_ended(struct gpio_chip *gc, + unsigned offset, + enum single_ended_mode mode) +{ + struct tps65218_gpio *tps65218_gpio = gpiochip_get_data(gc); + struct tps65218 *tps65218 = tps65218_gpio->tps65218; + + switch (offset) { + case 0: + case 2: + /* GPO1 is hardwired to be open drain */ + if (mode == LINE_MODE_OPEN_DRAIN) + return 0; + return -ENOTSUPP; + case 1: + /* GPO2 is push-pull by default, can be set as open drain. */ + if (mode == LINE_MODE_OPEN_DRAIN) + return tps65218_clear_bits(tps65218, + TPS65218_REG_CONFIG1, + TPS65218_CONFIG1_GPO2_BUF, + TPS65218_PROTECT_L1); + if (mode == LINE_MODE_PUSH_PULL) + return tps65218_set_bits(tps65218, + TPS65218_REG_CONFIG1, + TPS65218_CONFIG1_GPO2_BUF, + TPS65218_CONFIG1_GPO2_BUF, + TPS65218_PROTECT_L1); + return -ENOTSUPP; + default: + break; + } + return -ENOTSUPP; +} + static struct gpio_chip template_chip = { .label = "gpio-tps65218", .owner = THIS_MODULE, @@ -156,6 +180,7 @@ static struct gpio_chip template_chip = { .direction_input = tps65218_gpio_input, .get = tps65218_gpio_get, .set = tps65218_gpio_set, + .set_single_ended = tps65218_gpio_set_single_ended, .can_sleep = true, .ngpio = 3, .base = -1,