From patchwork Fri Nov 17 22:35:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 10064071 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 7F102604D4 for ; Fri, 17 Nov 2017 22:36:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72CFC2AE50 for ; Fri, 17 Nov 2017 22:36:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6738D2AE55; Fri, 17 Nov 2017 22:36:46 +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 43CFA2AE51 for ; Fri, 17 Nov 2017 22:36:45 +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=2meMzsYgmgjS3t55H2V7nrZtW9Tps7lkhD5HPOsy09g=; b=bmZwYhGuMcRRsF9z3wCXFknIi4 I+CrDUtwQfBKcySt6NBy5AjUU5BR7eU2fZ9x2o7QFAn6hmE7rKXw6z/Dl7TEIxLcxtwH1NwktI5pv 5tGlS04bdj/mwXLylNIgm9jI/sgXCDOLGSiSuj8QxlElVRcmsfm7G3L/f5W+w/YuPdPCNyT7tVkc9 HAgQJlBxvH1uOuU/RrzeSdW5ND09vS5u3GC8TZA7Aj8duHmRj2wir1OlXVdATXggCDQmfSVBNrEjx 1NN2BEK+oTSPfL28nUUq1xp9sPPMZBzt55EAJnWXD9YQoJEw8A5aPhPd5TCjK87RY+f0GGU2DdMah YnfB3utw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eFpFP-0003hF-5s; Fri, 17 Nov 2017 22:36:31 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eFpFL-0003em-Em for linux-amlogic@lists.infradead.org; Fri, 17 Nov 2017 22:36:29 +0000 Received: by mail-wr0-x241.google.com with SMTP id z14so3322444wrb.8 for ; Fri, 17 Nov 2017 14:36:07 -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=PU/oTOESab5Ps46EOmZn7U6gIBcAIkb8shUUolZO0zU=; b=UY9dOa9moqJYLbCtzinkV8IJwURM9EYbPh3P5t8FbDKW3FTKPIE+en7HTiNyi1pEnX TNlnnDeCpzX/cprchYAzm1aMNSmuud2YjGfWV2jeVfiP/8s8QwyfeQQo4N1veM6AG3ir sJACrmADdY+6F/dX88iTGahbh7xF+7bEUpBrIH3u6IiM/898jQGGW3TN/swC3DQOeqCf JmK1k36TbX/kMOKYdOCidAmh5a1o8tMqIOYS8s62FbmKA+nZEF9S6fFIMBjXdmSoFSzU QvjuFcjf9mjuBElBMqBQI97OhIKcDqcVhvfIDdZNxEqtEwpfC2JVwuQLgOsf2XIycnoJ 90Lw== 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=PU/oTOESab5Ps46EOmZn7U6gIBcAIkb8shUUolZO0zU=; b=kF7zFuwTU4rd1i54FCiUg5mnnDmk7gmLnHwULeXLDgfs+7Txqe9S1C2sZZ6K3P8M2b Kt7RTVJDjN0KMJw88D+d7pY6g1Za5q2A9t7fldV1jo8NeZUYwQofGexSD6hvYg5E7844 UlyjQELCnahxKmlq+oLF2YGEYtGWZzrW1v1D0Ou0Vm4IMBU6Uqx9FrJnLqdS9m0/CEZi cHLjkWALVpmKJM8Lng2KyyLmLl4jGpFsEqtFzVWfTFQB7lpOqjb9vPZvz2RLVbRevSlM 7ec9VLVh6CsB0tklGK6euAjvq6b+eYeti1NpP98/N8trXBiW5KlGv8uHAthyh5KC5Q8m B+Dw== X-Gm-Message-State: AJaThX6lmY2AI2tTmeaobKbNU+h6jEN04ShNYbJrhpJI+WUNpW0pN6nm kD+rVxiw87MbbuY06en8nGQ= X-Google-Smtp-Source: AGs4zMaOVE4wM0grywYNSUJlfHy+gmJc48zm10te7ZA4oWa1Hoa8isw0JxWIxNJYTKwyEJDUmjUKtQ== X-Received: by 10.223.197.141 with SMTP id m13mr5764840wrg.203.1510958166433; Fri, 17 Nov 2017 14:36:06 -0800 (PST) Received: from blackbox.darklights.net (p200300DCD3F8BE04428D5CFFFEB99DB8.dip0.t-ipconnect.de. [2003:dc:d3f8:be04:428d:5cff:feb9:9db8]) by smtp.googlemail.com with ESMTPSA id k5sm5094876wmg.21.2017.11.17.14.36.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Nov 2017 14:36:05 -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 v1 1/8] serdev: implement parity configuration Date: Fri, 17 Nov 2017 23:35:36 +0100 Message-Id: <20171117223543.32429-2-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171117223543.32429-1-martin.blumenstingl@googlemail.com> References: <20171117223543.32429-1-martin.blumenstingl@googlemail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171117_143627_662912_64745477 X-CRM114-Status: GOOD ( 10.22 ) 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, linux-sunxi@googlegroups.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 | 3 +++ 3 files changed, 36 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 ce7ad0acee7a..418548ba8992 100644 --- a/drivers/tty/serdev/serdev-ttyport.c +++ b/drivers/tty/serdev/serdev-ttyport.c @@ -170,6 +170,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); @@ -207,6 +227,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 e69402d4a8ae..ccc541aa5c70 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,7 @@ 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 *, bool, bool) {} static inline int serdev_device_write_buf(struct serdev_device *serdev, const unsigned char *buf, size_t count)