From patchwork Tue Mar 22 13:12:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yegor Yefremov X-Patchwork-Id: 8642231 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7A7019F3D1 for ; Tue, 22 Mar 2016 13:14:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8A50D20396 for ; Tue, 22 Mar 2016 13:14:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9E909201EF for ; Tue, 22 Mar 2016 13:14:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759124AbcCVNOL (ORCPT ); Tue, 22 Mar 2016 09:14:11 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:32853 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758941AbcCVNNo (ORCPT ); Tue, 22 Mar 2016 09:13:44 -0400 Received: by mail-wm0-f66.google.com with SMTP id u125so3587606wmg.0; Tue, 22 Mar 2016 06:13:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=725HfGgGIhV7z/cTQgJtQ1Vo0t64nRMhXT2TPLdreRg=; b=cgBHM1hmqWJ4zNPQSfbrjbinqYIWxa1Sy2lElb2Y23puUIvUTyhS5DxLzGdFcafXdl AcXfkL5hwV5Cq4vMydlUAchllG4pPvN8kEMjq3sDk3p0xNcp3nWwtdqIYo7QdUqO8buv cJ71HQmhmn6iJBd/ej/AwkZg3FkYjVdJm4pO1WB5HFpfadTgA3iNS05Yr6zK/b7cnGvd Rk/SCv+8bGLD/yoed5V437ElfPCVzbTQWg3Sgp2iHOjhBDnLg2g40BtP8it3oHMPNXKU CKHBTyx0gJV7xiPUJIFRbunhPe/LGOXMgJx6Wyb9AeKjrJy3Rqcf27WEV2iHfGr/qq8C DQBg== 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:in-reply-to :references; bh=725HfGgGIhV7z/cTQgJtQ1Vo0t64nRMhXT2TPLdreRg=; b=HZySv1AJJcfLWum9Y8V3bRTHD55lHmSfbIA9yymNSDKWF2uqA0cKe57E69SUBA+/vF xQ8mWakQCMFpkOfZLto9fjET6OVGkjQ+rAdcjyAw3rWzDV+CnEdaNkkvNHvCvA53XH7A dUhJtNm+jNVftLpnIYi/9sTogaJJbKmywGe6imNJZEYAXfIIPVp2QkaqCbJTYnQR0T3X reOtsnLnJZEJjjg05xGVYIwfvg0pg4tqZ0Zs7DI49E50DOLCp0FgVY1l8aHgrYcg4s4G 52mC2kocT7dxxQhV0tNqgGwP5mAPzKs95rHkJGrwzZX5kNaDPRDufz9MZenIGnjNeZqj rdvw== X-Gm-Message-State: AD7BkJKCRiCziXixb1GVaKvqjBlj3XODM1tnWcQh7c7t1ZJ+lCFe3rPY8J9YwnHnouC/vg== X-Received: by 10.28.101.133 with SMTP id z127mr20654884wmb.84.1458652422172; Tue, 22 Mar 2016 06:13:42 -0700 (PDT) Received: from development1.visionsystems.de (mail.visionsystems.de. [213.209.99.202]) by smtp.gmail.com with ESMTPSA id y72sm17384561wmh.21.2016.03.22.06.13.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Mar 2016 06:13:41 -0700 (PDT) From: yegorslists@googlemail.com To: linux-serial@vger.kernel.org Cc: linux-omap@vger.kernel.org, gregkh@linuxfoundation.org, nm@ti.com, bigeasy@linutronix.de, tony@atomide.com, nsekhar@ti.com, Yegor Yefremov Subject: [PATCH v2 3/5] serial: mctrl_gpio: add modem control read routine Date: Tue, 22 Mar 2016 14:12:07 +0100 Message-Id: <1458652329-10138-4-git-send-email-yegorslists@googlemail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1458652329-10138-1-git-send-email-yegorslists@googlemail.com> References: <1458652329-10138-1-git-send-email-yegorslists@googlemail.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Yegor Yefremov mctrl_gpio_get_outputs() returns the state of following signals: RTS, DTR, OUT1, OUT2 Signed-off-by: Yegor Yefremov --- drivers/tty/serial/serial_mctrl_gpio.c | 18 ++++++++++++++++++ drivers/tty/serial/serial_mctrl_gpio.h | 15 ++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/serial_mctrl_gpio.c b/drivers/tty/serial/serial_mctrl_gpio.c index 0214736..bb5e4f9 100644 --- a/drivers/tty/serial/serial_mctrl_gpio.c +++ b/drivers/tty/serial/serial_mctrl_gpio.c @@ -88,6 +88,24 @@ unsigned int mctrl_gpio_get(struct mctrl_gpios *gpios, unsigned int *mctrl) } EXPORT_SYMBOL_GPL(mctrl_gpio_get); +unsigned int +mctrl_gpio_get_outputs(struct mctrl_gpios *gpios, unsigned int *mctrl) +{ + enum mctrl_gpio_idx i; + + for (i = 0; i < UART_GPIO_MAX; i++) { + if (gpios->gpio[i] && mctrl_gpios_desc[i].dir_out) { + if (gpiod_get_value(gpios->gpio[i])) + *mctrl |= mctrl_gpios_desc[i].mctrl; + else + *mctrl &= ~mctrl_gpios_desc[i].mctrl; + } + } + + return *mctrl; +} +EXPORT_SYMBOL_GPL(mctrl_gpio_get_outputs); + struct mctrl_gpios *mctrl_gpio_init_noauto(struct device *dev, unsigned int idx) { struct mctrl_gpios *gpios; diff --git a/drivers/tty/serial/serial_mctrl_gpio.h b/drivers/tty/serial/serial_mctrl_gpio.h index 9716db2..e8ad5e6 100644 --- a/drivers/tty/serial/serial_mctrl_gpio.h +++ b/drivers/tty/serial/serial_mctrl_gpio.h @@ -50,12 +50,19 @@ struct mctrl_gpios; void mctrl_gpio_set(struct mctrl_gpios *gpios, unsigned int mctrl); /* - * Get state of the modem control output lines from GPIOs. + * Get state of the modem control input lines from GPIOs. * The mctrl flags are updated and returned. */ unsigned int mctrl_gpio_get(struct mctrl_gpios *gpios, unsigned int *mctrl); /* + * Get state of the modem control output lines from GPIOs. + * The mctrl flags are updated and returned. + */ +unsigned int +mctrl_gpio_get_outputs(struct mctrl_gpios *gpios, unsigned int *mctrl); + +/* * Returns the associated struct gpio_desc to the modem line gidx */ struct gpio_desc *mctrl_gpio_to_gpiod(struct mctrl_gpios *gpios, @@ -109,6 +116,12 @@ unsigned int mctrl_gpio_get(struct mctrl_gpios *gpios, unsigned int *mctrl) return *mctrl; } +static inline unsigned int +mctrl_gpio_get_outputs(struct mctrl_gpios *gpios, unsigned int *mctrl) +{ + return *mctrl; +} + static inline struct gpio_desc *mctrl_gpio_to_gpiod(struct mctrl_gpios *gpios, enum mctrl_gpio_idx gidx)