Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1229256imm; Wed, 6 Jun 2018 12:30:36 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKUUuM0YdIkaEvyCJ6JTf+qXRDPelI7Xf359Sj4Nn2W33OuwaU10VMAq7IOpIPB00mIJkUU X-Received: by 2002:a17:902:6102:: with SMTP id t2-v6mr4635075plj.392.1528313436115; Wed, 06 Jun 2018 12:30:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528313436; cv=none; d=google.com; s=arc-20160816; b=C7SQSvN/QHf97Ryk7MCnaV5HChpxx9hAVOKIvwBCnbkUXGGG0Q4+eC0SIpSOPX8Ywl FELo9CsHDBFvJOpJUtOTCVxbufYM9OhpLnR+HuaFu67rLUwUEKZA8RvJQD84bIcXI5Aw AWf2vYMoVpSHPzzo3P0czUaDCXUyvOdDMWx5ickq3N9SDDzaBG/AUBKSOce1N/D3xkxh G2f4dqPNEM/A9pZWqcBSfY8+UOo66c0wcUDHgvJDlg6sjMXaxS6ElsSA4KIFUyuqWj5W FAJJy53DMX0Pby9//Y+/T700ldK5FdnMDxF0vdqoS3zM6mKxgTnfT/Qt2zvNlLGaaKg4 LW4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=mJ19XGIdCUog0MpiLM/AFgV8pJ1L7Q2i3ZR8i/QTdnw=; b=FikCmacaD148glVcJZqzfO/UrO9QGzX04r4dhT+LwkS9gceoMCeQ4fH7GI2Dl8LThh wkodsKNiM+c/FuY6NI1Bx2YggRmwA22iM/YKXkTahO0dBhdBuryacM4otXTpVHIBbl41 mW/qbAwx6q9uJJj5f9cGTmbJgH+h1vt4bYBHvVqUWehvheTIrSJUGs3tf0tR9jgM63gD VNGj/5uNPxhLs3qpc/b7dfgkvlOhHejkG3/JTNQFa58ST5wMf3SAOxpDaub/nda16MKg kdW8gr+wZzKRbR7KBjkB8TCObbRBmrTjhGqdgjuWK8nc7Wx3UCbBEAzyT9/473tb5zi9 bv9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@micronovasrl.com header.s=dkim header.b=d1TBjwfm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w10-v6si25546840ply.482.2018.06.06.12.30.22; Wed, 06 Jun 2018 12:30:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=temperror (no key for signature) header.i=@micronovasrl.com header.s=dkim header.b=d1TBjwfm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753051AbeFFTQv (ORCPT + 99 others); Wed, 6 Jun 2018 15:16:51 -0400 Received: from mail.micronovasrl.com ([212.103.203.10]:45626 "EHLO mail.micronovasrl.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752042AbeFFTQu (ORCPT ); Wed, 6 Jun 2018 15:16:50 -0400 Received: from mail.micronovasrl.com (mail.micronovasrl.com [127.0.0.1]) by mail.micronovasrl.com (Postfix) with ESMTP id A2C7DB007F4 for ; Wed, 6 Jun 2018 21:16:48 +0200 (CEST) Authentication-Results: mail.micronovasrl.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=micronovasrl.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=micronovasrl.com; h=content-transfer-encoding:content-language:content-type :content-type:in-reply-to:mime-version:user-agent:date:date :message-id:from:from:references:to:subject:subject; s=dkim; t= 1528312608; x=1529176609; bh=GRa+kGHrvsw8/K+Jk99ORQPVwaluiAm/YhE A/Iq8ZcA=; b=d1TBjwfmyJS7lRc28Q6tGAf0wEPusmYXfdU3g0oIByyzbrBQKOY 7bRgw281vOCTw9eP0qwxiGFcCuqoT3NRGzjSAfo+mwxhVAN9yZZnXiijkTa4+S5k kX260/TJIUT7Hxt+RceGAfwRGH6rhBMnj+RFZXXEvQq1BB7stNbsNkUc= X-Virus-Scanned: Debian amavisd-new at mail.micronovasrl.com X-Spam-Flag: NO X-Spam-Score: -2.9 X-Spam-Level: X-Spam-Status: No, score=-2.9 tagged_above=-10 required=4.5 tests=[ALL_TRUSTED=-1, BAYES_00=-1.9] autolearn=unavailable autolearn_force=no Received: from mail.micronovasrl.com ([127.0.0.1]) by mail.micronovasrl.com (mail.micronovasrl.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id bHd4-edbNoCj for ; Wed, 6 Jun 2018 21:16:48 +0200 (CEST) Received: from [192.168.2.109] (62-11-51-166.dialup.tiscali.it [62.11.51.166]) by mail.micronovasrl.com (Postfix) with ESMTPSA id 7C4CAB00309; Wed, 6 Jun 2018 21:16:40 +0200 (CEST) Subject: Re: [PATCH 1/4] serial: 8250_dw: add em485 support To: Andy Shevchenko Cc: "Matwey V. Kornilov" , Andy Shevchenko , Greg Kroah-Hartman , Jiri Slaby , Ed Blake , Joshua Scott , "open list:SERIAL DRIVERS" , open list References: <20180606095156.72628-1-giulio.benetti@micronovasrl.com> <20180606095156.72628-4-giulio.benetti@micronovasrl.com> From: Giulio Benetti Message-ID: <9d8bdd5b-842f-8943-a186-a99f31d71a2a@micronovasrl.com> Date: Wed, 6 Jun 2018 21:16:37 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: it Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Il 06/06/2018 18:51, Andy Shevchenko ha scritto: > On Wed, Jun 6, 2018 at 12:51 PM, Giulio Benetti > wrote: >> Need to use rs485 transceiver so let's use existing em485 485 emulation >> layer on top of 8250. >> >> Add rs485_config callback to port. > > Besides the fact the series lacks of cover letter, I think it should Sorry for that, next patchsets will have cover-letters. > be postponed until we get a clear understanding how RS485 is supposed > to be initialized and what exact problems you are trying to address. > >> >> Signed-off-by: Giulio Benetti >> --- >> drivers/tty/serial/8250/8250_dw.c | 31 +++++++++++++++++++++++++++++++ >> 1 file changed, 31 insertions(+) >> >> diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c >> index 6fcdb90f616a..45366e6e5411 100644 >> --- a/drivers/tty/serial/8250/8250_dw.c >> +++ b/drivers/tty/serial/8250/8250_dw.c >> @@ -314,6 +314,36 @@ static void dw8250_set_ldisc(struct uart_port *p, struct ktermios *termios) >> serial8250_do_set_ldisc(p, termios); >> } >> >> +static int dw8250_rs485_config(struct uart_port *p, >> + struct serial_rs485 *rs485) >> +{ >> + struct uart_8250_port *up = up_to_u8250p(p); >> + >> + /* Clamp the delays to [0, 100ms] */ >> + rs485->delay_rts_before_send = min(rs485->delay_rts_before_send, 100U); >> + rs485->delay_rts_after_send = min(rs485->delay_rts_after_send, 100U); >> + >> + p->rs485 = *rs485; >> + >> + /* >> + * Both serial8250_em485_init and serial8250_em485_destroy >> + * are idempotent >> + */ >> + if (rs485->flags & SER_RS485_ENABLED) { >> + int ret = serial8250_em485_init(up); >> + >> + if (ret) { >> + rs485->flags &= ~SER_RS485_ENABLED; >> + p->rs485.flags &= ~SER_RS485_ENABLED; >> + } >> + return ret; >> + } >> + >> + serial8250_em485_destroy(up); >> + >> + return 0; >> +} >> + >> /* >> * dw8250_fallback_dma_filter will prevent the UART from getting just any free >> * channel on platforms that have DMA engines, but don't have any channels >> @@ -449,6 +479,7 @@ static int dw8250_probe(struct platform_device *pdev) >> p->serial_out = dw8250_serial_out; >> p->set_ldisc = dw8250_set_ldisc; >> p->set_termios = dw8250_set_termios; >> + p->rs485_config = dw8250_rs485_config; >> >> p->membase = devm_ioremap(dev, regs->start, resource_size(regs)); >> if (!p->membase) >> -- >> 2.17.1 >> > > > -- Giulio Benetti CTO MICRONOVA SRL Sede: Via A. Niedda 3 - 35010 Vigonza (PD) Tel. 049/8931563 - Fax 049/8931346 Cod.Fiscale - P.IVA 02663420285 Capitale Sociale € 26.000 i.v. Iscritta al Reg. Imprese di Padova N. 02663420285 Numero R.E.A. 258642