From patchwork Mon May 23 07:30:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yegor Yefremov X-Patchwork-Id: 9131269 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3DD76607D3 for ; Mon, 23 May 2016 07:32:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 341B42820E for ; Mon, 23 May 2016 07:32:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 28CAF28218; Mon, 23 May 2016 07:32:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BCFF62820E for ; Mon, 23 May 2016 07:32:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753456AbcEWHcw (ORCPT ); Mon, 23 May 2016 03:32:52 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:36695 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752914AbcEWHcv (ORCPT ); Mon, 23 May 2016 03:32:51 -0400 Received: by mail-wm0-f67.google.com with SMTP id q62so12258651wmg.3; Mon, 23 May 2016 00:32:50 -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=LhPnX3KMI3LsJbCS5ywu/1sS1F2mikL2M+05lF2fTv0=; b=VQhqTm+Ua1LNkV0rghCL5OAjr2PSPTYk4vmGeUTWxvZu239C48oLXdm9w07NSvgrkX 2y0XrM9Cx9XLy5JU7eS2AVe2zoFjxi+AQDCUHvE0flZTWWFcXlmKkuXIMng90mguR5tD TgUOLTnOZ3Of9StqCBSwd7qj+V0ErEchgyZFOwaaTedykYhPRmXEKiqHO+qcEq0IYIGV fcmcJfrmcLoXgq8BouELFjnkvnRbxbEP3+gW5RBaGFAo/qoJsT4MujJ07WqtfwRhKCwB Tr0s6aHZ5gGiOYxphxwXvLkHRCz8TfP6VerLy/sEUiTt+APYfSqC3kUp6ZFarFsSkH0J 2u8w== 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=LhPnX3KMI3LsJbCS5ywu/1sS1F2mikL2M+05lF2fTv0=; b=ZJfjh5GelUo0lqUVvD0ttGpMiOG+9pZ0VxK/6vUMoRNgfwFs6kK/JbO3ey91+yfRF9 mKZlwA2Fn+eDW8Furq9TSiD6y1pDOrFr/Gm9U73jZELDD63NXL+dgdI70cJnL3QyHyZS O73EmRhjYR7T0Jmo04uDfmPxaEmqTsZzV46hPGa54URCFarFnS20YJRA0DimZ4zvh1aa owWkvCUYuwP+9ihMb78uYytgsntHMMtOfdchyZV653DSCdWv93PYJccfOefwah2TdG4M qin0gmnmCMDonpKYIbeGgUhoKG5MIv9buZkqhkZFg8WfYTZZPfWcBosNyYFTZew7Msyj nnlg== X-Gm-Message-State: AOPr4FXk0JiqjFio+vEtmo+NmXplxl6EGmQuMMXLphu/Fk8e9Ghz3Aw/kF9mECeznqZbdA== X-Received: by 10.28.146.70 with SMTP id u67mr16435493wmd.36.1463988770194; Mon, 23 May 2016 00:32:50 -0700 (PDT) Received: from development1.visionsystems.de (mail.visionsystems.de. [213.209.99.202]) by smtp.gmail.com with ESMTPSA id o76sm10399991wme.0.2016.05.23.00.32.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 May 2016 00:32:49 -0700 (PDT) From: yegorslists@googlemail.com To: linux-serial@vger.kernel.org Cc: linux-omap@vger.kernel.org, gregkh@linuxfoundation.org, u.kleine-koenig@pengutronix.de, peter@hurleysoftware.com, Yegor Yefremov Subject: [PATCH v4 2/4] serial: mctrl_gpio: add modem control read routine Date: Mon, 23 May 2016 09:30:56 +0200 Message-Id: <1463988658-9183-3-git-send-email-yegorslists@googlemail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1463988658-9183-1-git-send-email-yegorslists@googlemail.com> References: <1463988658-9183-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-Virus-Scanned: ClamAV using ClamSMTP From: Yegor Yefremov mctrl_gpio_get_outputs() returns the state of following signals: RTS, DTR 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 e8dd509..a868595 100644 --- a/drivers/tty/serial/serial_mctrl_gpio.c +++ b/drivers/tty/serial/serial_mctrl_gpio.c @@ -86,6 +86,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 332a33a..fa000bc 100644 --- a/drivers/tty/serial/serial_mctrl_gpio.h +++ b/drivers/tty/serial/serial_mctrl_gpio.h @@ -48,12 +48,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, @@ -107,6 +114,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)