From patchwork Thu Feb 21 17:17:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kepplinger X-Patchwork-Id: 10824405 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7A105922 for ; Thu, 21 Feb 2019 17:18:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4FDC42022B for ; Thu, 21 Feb 2019 17:18:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3EBB831181; Thu, 21 Feb 2019 17:18:37 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 6AB9E2022B for ; Thu, 21 Feb 2019 17:18:36 +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-Type:Cc: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: MIME-Version:Message-ID:Date:Subject:To:From:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=gNh6J9M0ynyKej3o8eurLzbBYvXilI45gBwbMYuZz94=; b=H7e KfD39XTgB1HHvw1S5N9HswzGIews1V7FnzWQ9o3zJD7tKvfNgrH7J3Wz39w5h22Wsam7e/mlmhT1A apwVowRrb/YE12yQKZ/zDcVkYXH78SKTue1wMg1J5m9yPZ2IoTKFR5BkSCiDTlASbEE12BXQnPu1m ZPdxp3iIJPYLXf1D8cW3Yh+EA4X9KP+6xzPVWsnenGUuegfyfSsBg/VSm2n4YXpAaRJeze2m062B3 7Jj5kwdIWbkRl1BpAPj55vlivLHBsehOoZRRQ0Gv7Oq2/FGGbn5/lZEczG1M7vMBZMFWDa0fh/+Gg ZUH7iznNDlT85hvWmhcH/q72ENtnDfQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gwrzW-00062b-Kl; Thu, 21 Feb 2019 17:18:34 +0000 Received: from mx-ginzinger.sigmacloud.services ([185.154.235.147]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gwrzS-00061Z-OL for linux-arm-kernel@lists.infradead.org; Thu, 21 Feb 2019 17:18:32 +0000 Received: from [31.193.165.228] (port=9228 helo=mx-ginzinger.sigmacloud.services) by mx-ginzinger.sigmacloud.services with esmtps (TLSv1.2:AES256-GCM-SHA384:256) (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1gwrzH-00028o-2Y; Thu, 21 Feb 2019 18:18:19 +0100 Received: from martin-laptop.buero.ginzinger.com (10.10.1.120) by exc1.buero.ginzinger.com (10.1.1.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1466.3; Thu, 21 Feb 2019 18:18:19 +0100 X-CTCH-RefID: str=0001.0A0B020F.5C6EDD5B.0066, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 From: Martin Kepplinger To: , , , , , , , , , , , , , , Subject: [PATCH v2 1/9] serial: uapi: add SER_RS485_DELAY_IN_USEC flag to struct serial_rs485 Date: Thu, 21 Feb 2019 18:17:50 +0100 Message-ID: <20190221171758.10322-1-martin.kepplinger@ginzinger.com> X-Mailer: git-send-email 2.20.1 X-Originating-IP: [10.10.1.120] X-ClientProxiedBy: exc1.buero.ginzinger.com (10.1.1.204) To exc1.buero.ginzinger.com (10.1.1.204) X-EXCLAIMER-MD-ORIGINAL-SUBJECT: [NOSIG][NODISC][PATCH v2 1/9] serial: uapi: add SER_RS485_DELAY_IN_USEC flag to struct serial_rs485 X-EXCLAIMER-MD-CONFIG: 9dd172f7-de2e-4231-b886-ec11f46e03b3 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190221_091830_947255_6116577E X-CRM114-Status: GOOD ( 19.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Martin Kepplinger , linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This extends the user interface for rs485 communication: We add a new flag, SER_RS485_DELAY_IN_USEC, to struct serial_rs485 that indicates that delay_rts_before_send and delay_rts_after_send values are interpreted in microsecond units. Up until now, the code comment defined these values to hold the delays in millisecond units. Especially with fast data rates (1Mbaut or more) that are not too uncommon for RS485, 1ms become quite long. Users need to be able to set shorter delays than 1 ms in order not to slow down the channel unnecessarily. So when delays are needed, but not as long as 1ms, this enables faster communication channels without changing the baudrate. Signed-off-by: Martin Kepplinger --- revision history ---------------- v2: re-send as a proper series after fixing my mailserver v1: initial implementation idea So have this totally quirky patch that uses udelay() in our tree for a looong time now because of the above reasons - and because we are lazy. This is an attempt to get rid of said patch on our side and fix this properly. What do you thing about adding a flag in general? The following patches should integrate this idea in devicetree and drivers. These changes are NOT tested on hardware but should behave predictably enough. I use the delays in a driver that doesn't implement them yet at all. I'll do that after this (or something similar) is merged - it's a 2-liner then. Also, a patch to the rs485conf tool, that is sometimes used instead of ioctl() directly, will be prepared as well. thanks martin include/uapi/linux/serial.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/uapi/linux/serial.h b/include/uapi/linux/serial.h index 93eb3c496ff1..c16c950ebca2 100644 --- a/include/uapi/linux/serial.h +++ b/include/uapi/linux/serial.h @@ -126,8 +126,15 @@ struct serial_rs485 { #define SER_RS485_TERMINATE_BUS (1 << 5) /* Enable bus termination (if supported) */ - __u32 delay_rts_before_send; /* Delay before send (milliseconds) */ - __u32 delay_rts_after_send; /* Delay after send (milliseconds) */ +#define SER_RS485_DELAY_IN_USEC (1 << 6) /* delay_rts_*_send + values are given in + microseconds */ + __u32 delay_rts_before_send; /* Delay before send (milliseconds + by default. microseconds if flag + is set) */ + __u32 delay_rts_after_send; /* Delay after send (milliseconds + by default. microseconds if flag + is set) */ __u32 padding[5]; /* Memory is cheap, new structs are a royal PITA .. */ };