From patchwork Mon Jan 1 20:42:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 10139569 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 49B80601A1 for ; Mon, 1 Jan 2018 20:43:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C20628639 for ; Mon, 1 Jan 2018 20:43:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 304E7288D1; Mon, 1 Jan 2018 20:43:01 +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=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BC3F1288CF for ; Mon, 1 Jan 2018 20:43:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=qyZDp/1lvpnBV2ur1Z/PO2w/1bI5zohB4sqXYfNGUtk=; b=ESiuDP0q8DfMM/jbxdqJM+nsdL R2nupQvd+q1HjPLOb1npnEn08R/GRbRo91AywpPohp0EKubvfSbY6DU9W4LrQUeJsLPvs2ShUngEy 1V5w/qDI+CzGp0xcNcLIoR4wL42UZNoVI6iLLUyXt45JrymcdlzIVr9ORwiTdklWwWeC7DOzjNr36 15HywYaUmJ0ZO4FuV9q5nTyNwqwAVPGS7GPk+sH9qT9N56Yf1Py/aqHSvpY09ZmEHV4z/yEq+iYDh m/Ttd3FvXHjt8De5UFi4eJFcXRaXR7mDlVTk0WyH9L3oF7mYcmOH6yxuQXKg4rYS0D4Ea1o5S1L9O TzsPU3bg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eW6v3-00036c-9d; Mon, 01 Jan 2018 20:42:49 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eW6uw-000328-Do for linux-amlogic@lists.infradead.org; Mon, 01 Jan 2018 20:42:45 +0000 Received: by mail-wm0-x243.google.com with SMTP id g75so58740417wme.0 for ; Mon, 01 Jan 2018 12:42:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=s1lphQ3MnWcM6ZanQUaNpjGnHnBeK3k4P6jicv8/GD4=; b=f99zYroZYsU0Fta+9iQFUakjdQcyFA1oTg77NbW/vdI4rx8bIJI3aaANrwZRxWcwiH JoCLEROp008WGH+JI9sJ1o51niVEjk6S+9O4aqTi483YmkMc86KNUeJCQchhbQHGyD3b pAzAKyZd/c9o/do5zcf0/BLrInXVyQvkKlpTXPD+lR/WVtn6fo48ZeRuIgp0iZfndpuf OsDltIVhsEHvML6gGbeVaemx0ZSjW03PEDEZAJhQAy9LmfPjWULyJAKkh6327Vl1IPMo iugiOK6xG9KyZfZHZ/mLT4+VWjJYBLNWaciq2Hv2/4YzsLjJqtw2ps+WO1z+Z2GRvEpk DfXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=s1lphQ3MnWcM6ZanQUaNpjGnHnBeK3k4P6jicv8/GD4=; b=X7esNf4pJDy3XJj+tBtN0ZvZsdqOopcmgZ+oXlIvM2VyoDk3Dhgo7hNe7dzBuLjYvP eKupqHo9Awg7h5F+7c4SUY6btaBTuIg0WSVViFcPqmK6f2GAZGfDMvMs1U9Z1wzjKEnT yJZUH6AkDKQmbSnKg8/H4vtAlbuTDipid4b+qUhIxw+bOlXjOeex8bYHLOGtE5WyQVzJ d70y7HbFUaQQ4QDPJCDJlO41XKHn7q32JiYgVvh1TmNwJof9FhZQUSPKdDjxBoyzCn8V j0Ryomnves88r2eth0hcuhHXklbtkD1P9woFZfKMYjDu4R7UBvODLHNeXncu9zc27EX0 zjzA== X-Gm-Message-State: AKGB3mLTOd5ywEnyGYV74Q5VCfGik/PISCBiXx8TzYJIsg9UqOfDdeh2 nkLiaI+lFd4XNwBptQt7i9M= X-Google-Smtp-Source: ACJfBovjMocR1KKehdqnOI0OACiYxPU86R03tjnmN2lMknuEdKa4E0Dj5xCeJYHDKks8uF/Gp7gh4w== X-Received: by 10.28.54.207 with SMTP id y76mr38198780wmh.94.1514839350559; Mon, 01 Jan 2018 12:42:30 -0800 (PST) Received: from blackbox.darklights.net (p5DE386EE.dip0.t-ipconnect.de. [93.227.134.238]) by smtp.googlemail.com with ESMTPSA id c53sm57657032wrg.10.2018.01.01.12.42.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Jan 2018 12:42:29 -0800 (PST) From: Martin Blumenstingl To: robh+dt@kernel.org, devicetree@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-serial@vger.kernel.org Subject: [RFC v2 1/9] serdev: implement parity configuration Date: Mon, 1 Jan 2018 21:42:09 +0100 Message-Id: <20180101204217.26165-2-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180101204217.26165-1-martin.blumenstingl@googlemail.com> References: <20180101204217.26165-1-martin.blumenstingl@googlemail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180101_124242_518762_FEABF439 X-CRM114-Status: GOOD ( 10.48 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, johan.hedberg@gmail.com, gregkh@linuxfoundation.org, Martin Blumenstingl , gustavo@padovan.org, marcel@holtmann.org, johan@kernel.org, drake@endlessm.com, carlo@endlessm.com, jslaby@suse.com, linux-amlogic@lists.infradead.org, Larry.Finger@lwfinger.net MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Some Bluetooth modules (for example the ones found in Realtek RTL8723BS and RTL8723DS) want to communicate with the host with even parity enabled. Add a new function and the corresponding internal callbacks so parity can be configured. This supports enabling and disabling parity as well as setting the type to odd or even. Signed-off-by: Martin Blumenstingl --- drivers/tty/serdev/core.c | 12 ++++++++++++ drivers/tty/serdev/serdev-ttyport.c | 21 +++++++++++++++++++++ include/linux/serdev.h | 5 +++++ 3 files changed, 38 insertions(+) diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c index 1bef39828ca7..d327b02980f5 100644 --- a/drivers/tty/serdev/core.c +++ b/drivers/tty/serdev/core.c @@ -225,6 +225,18 @@ void serdev_device_set_flow_control(struct serdev_device *serdev, bool enable) } EXPORT_SYMBOL_GPL(serdev_device_set_flow_control); +void serdev_device_set_parity(struct serdev_device *serdev, bool enable, + bool odd) +{ + struct serdev_controller *ctrl = serdev->ctrl; + + if (!ctrl || !ctrl->ops->set_parity) + return; + + ctrl->ops->set_parity(ctrl, enable, odd); +} +EXPORT_SYMBOL_GPL(serdev_device_set_parity); + void serdev_device_wait_until_sent(struct serdev_device *serdev, long timeout) { struct serdev_controller *ctrl = serdev->ctrl; diff --git a/drivers/tty/serdev/serdev-ttyport.c b/drivers/tty/serdev/serdev-ttyport.c index 247788a16f0b..36bed86e5c96 100644 --- a/drivers/tty/serdev/serdev-ttyport.c +++ b/drivers/tty/serdev/serdev-ttyport.c @@ -190,6 +190,26 @@ static void ttyport_set_flow_control(struct serdev_controller *ctrl, bool enable tty_set_termios(tty, &ktermios); } +static void ttyport_set_parity(struct serdev_controller *ctrl, bool enable, + bool odd) +{ + struct serport *serport = serdev_controller_get_drvdata(ctrl); + struct tty_struct *tty = serport->tty; + struct ktermios ktermios = tty->termios; + + if (enable) + ktermios.c_cflag |= PARENB; + else + ktermios.c_cflag &= ~PARENB; + + if (odd) + ktermios.c_cflag |= PARODD; + else + ktermios.c_cflag &= ~PARODD; + + tty_set_termios(tty, &ktermios); +} + static void ttyport_wait_until_sent(struct serdev_controller *ctrl, long timeout) { struct serport *serport = serdev_controller_get_drvdata(ctrl); @@ -227,6 +247,7 @@ static const struct serdev_controller_ops ctrl_ops = { .open = ttyport_open, .close = ttyport_close, .set_flow_control = ttyport_set_flow_control, + .set_parity = ttyport_set_parity, .set_baudrate = ttyport_set_baudrate, .wait_until_sent = ttyport_wait_until_sent, .get_tiocm = ttyport_get_tiocm, diff --git a/include/linux/serdev.h b/include/linux/serdev.h index d609e6dc5bad..07f2d4d4e88c 100644 --- a/include/linux/serdev.h +++ b/include/linux/serdev.h @@ -86,6 +86,7 @@ struct serdev_controller_ops { int (*open)(struct serdev_controller *); void (*close)(struct serdev_controller *); void (*set_flow_control)(struct serdev_controller *, bool); + void (*set_parity)(struct serdev_controller *, bool, bool); unsigned int (*set_baudrate)(struct serdev_controller *, unsigned int); void (*wait_until_sent)(struct serdev_controller *, long); int (*get_tiocm)(struct serdev_controller *); @@ -195,6 +196,7 @@ int serdev_device_open(struct serdev_device *); void serdev_device_close(struct serdev_device *); unsigned int serdev_device_set_baudrate(struct serdev_device *, unsigned int); void serdev_device_set_flow_control(struct serdev_device *, bool); +void serdev_device_set_parity(struct serdev_device *, bool, bool); int serdev_device_write_buf(struct serdev_device *, const unsigned char *, size_t); void serdev_device_wait_until_sent(struct serdev_device *, long); int serdev_device_get_tiocm(struct serdev_device *); @@ -237,6 +239,9 @@ static inline unsigned int serdev_device_set_baudrate(struct serdev_device *sdev return 0; } static inline void serdev_device_set_flow_control(struct serdev_device *sdev, bool enable) {} +static inline void serdev_device_set_parity(struct serdev_device *sdev, + bool enable, + bool odd) {} static inline int serdev_device_write_buf(struct serdev_device *serdev, const unsigned char *buf, size_t count)