Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1063371imm; Wed, 6 Jun 2018 09:54:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKTsAS+MzGFmPt0Is2MhLHSTswnv7foNbUiPXBjR8pypuov4KrJjuoEBPvLWLlNJPicVpNV X-Received: by 2002:a63:63c4:: with SMTP id x187-v6mr3243985pgb.9.1528304075067; Wed, 06 Jun 2018 09:54:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528304075; cv=none; d=google.com; s=arc-20160816; b=y/VHQHW+MXDyvcsFlU2Xs5QUyZp/nS4ZZFZUvujY5NRx24k8PeTmAkI1Qx3lma4CuN k4B+a5ZdEMltGqP/dfL09byUaqJ6N5JnszJNPZsK0WvbO8LqbrgCnx2y/M9kTVgaKu7t 3xAdiOCr2HAoR8g9KW0Ih4p5GYp707eAT2x2h4rAbU5wKeWdOmIREv7s/1Ziq6yhaDkj est/qKW+E0KXU18Ssvq0iMsCwXKNHaqVuztmFmIK37ZdQTs6toU4QcYnpbAudhSYD17Y rIxqtaPRCODKjkGGZfGK2SlDGdAzNoI4ZU3SW3swugyQb/1t7DT30R5lpcelZx1kJ9f+ cRxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=DQzT1YisKjjbyJn+KwYgzvCUVxjOGQla3xWi+8CITXE=; b=lDVWjH4R3oRoBKueuV5jBMyh/FtDM6w/F7gJPgvI0J3Gt8Yzg5GAnToXmMWbSJPke2 /Om5WDHx7ICdaXRDI6yz+hzQYgcMDeCwn4HZ1faPf4jsNuC87YzPW19ncDELYY+m7zXm qsfy7kL/iN/ZiHZH8sONcfbH97j7c9jyeCA1PdxGafQwwmOx9YfnrA4oWjBnlNegSMd7 4ofdwbHauotSBUsWURPVw88JTyPU+Slp2ANy1i/CGexaZM3jUaU1E29bsOizjUG8jADu 6hdIwv3eoWPwgmqwQG1DOllOePDFoKt0uCScsqXNKqmP9xViC5q0xehjB81Qg4K8F1/H R21g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JVENQxzp; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z7-v6si27756642pfn.247.2018.06.06.09.54.19; Wed, 06 Jun 2018 09:54:35 -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=pass header.i=@gmail.com header.s=20161025 header.b=JVENQxzp; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753607AbeFFQvv (ORCPT + 99 others); Wed, 6 Jun 2018 12:51:51 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:36209 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752425AbeFFQvs (ORCPT ); Wed, 6 Jun 2018 12:51:48 -0400 Received: by mail-qt0-f196.google.com with SMTP id o9-v6so7057684qtp.3; Wed, 06 Jun 2018 09:51:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=DQzT1YisKjjbyJn+KwYgzvCUVxjOGQla3xWi+8CITXE=; b=JVENQxzpu8JrkWq3wcnr+qbRMQ6yxnEJGJYR0kMESFXIPLgzP74fy12wdI/+f/WQjX MSSvDWeGPHCWB9gyaxchtxp23PCYnXzZrhVBBQCenIpq4EzoDjdYC4n1HUU7Oa7BqOKI rps2Y0OMCp18w1wbpqIXoloOBgLJkLZ2f0emmk9r/lbyZrSzgMaBYuvxiBULEsLmnDeX ZmqNqMWGEmzzA3Bq/XOoqJTJ/7Q60LAxLB1M+r7R9v8C0fH8G53gNAXe9Si5XDW7QpIS OxPltb1I6z+l23ba88UW8si5oyci2dlmweTLNn0VOZ4iRvL3Bqn3MIP6vT/gYk4QeKqt kkMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=DQzT1YisKjjbyJn+KwYgzvCUVxjOGQla3xWi+8CITXE=; b=foUVNuHT9p7aaykL4skKXxlu6KPeEJllZ2p1+Cp73l9iEJ4aLJkR+22Xtpdtn2n6KB 5WWABDXCzTss47K599AXwhtZdcZW2MmT9j6DaaQ2arpnVTet6i46772K7/qh8bls9zCA f0aDFrsyorT4RuWCeiGz/jr3WAdWXg9M0dmp7lzWpolGmho1+dtO1Pk15478cwEBHrd+ AFNUtdphx4rwGZcCbu7lHgEjzZji5il/d3iHK73zq+G+BkF4UYyt0llXZIscsceON3eR QCi74v+niVj0JBiP0ZgnKNR5LIXKSlQKKt21tZv/VGWUv/roR5a9HFEyQcFk+mOGf34J +EjA== X-Gm-Message-State: APt69E21YAEWezY/5TiQN6wJ+9kmOetYH44Xb5S2tyimoqj63IaXPFiU PrRroBCu2jv47ULOyDJormcgx7CFSBsIC6i6N5k= X-Received: by 2002:ac8:32f3:: with SMTP id a48-v6mr3378925qtb.404.1528303907299; Wed, 06 Jun 2018 09:51:47 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a0c:98f9:0:0:0:0:0 with HTTP; Wed, 6 Jun 2018 09:51:46 -0700 (PDT) In-Reply-To: <20180606095156.72628-4-giulio.benetti@micronovasrl.com> References: <20180606095156.72628-1-giulio.benetti@micronovasrl.com> <20180606095156.72628-4-giulio.benetti@micronovasrl.com> From: Andy Shevchenko Date: Wed, 6 Jun 2018 19:51:46 +0300 Message-ID: Subject: Re: [PATCH 1/4] serial: 8250_dw: add em485 support To: Giulio Benetti Cc: "Matwey V. Kornilov" , Andy Shevchenko , Greg Kroah-Hartman , Jiri Slaby , Ed Blake , Joshua Scott , "open list:SERIAL DRIVERS" , open list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 > -- With Best Regards, Andy Shevchenko