Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp665063pxb; Thu, 15 Apr 2021 03:48:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtNU9WHXwWSiQdCzAFF40ID1F4nJVVDRL/NxiCJjEFJeXkWvGIzn2CGFU4MnkT1sT8PT6p X-Received: by 2002:a17:906:8317:: with SMTP id j23mr2777492ejx.13.1618483719244; Thu, 15 Apr 2021 03:48:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618483719; cv=none; d=google.com; s=arc-20160816; b=f3AKaRLZaEbkvrNLpr+BYBj1LMiJOx/9UlnyNzVom54Mee1sSUnRFQdaw6UEKkcDc0 aFTtw6TDuGHRlhzJK2UWi6cY9VvCXmZGUKoXb3K5mxCkTwUSVsgBOlyqHcka99GcZ8Pg 1PbK7QYLaLfu2GDZPxAsXdgTF64gktLy6wNykXdhvnMUC3wmWiDJRhkIf6/ziu62uVek 1jdNOMySvlBrR8iXZUR23oU/U0Y4/Vlfe4fUyxhRqgSd77QuobSJcCW5aQvdBBK/kV7G ccYSCbwsWVArod40u9W4aBJDYxByJmujDavlQl5SV/gehRVadkGmtLHqbHBTx9Q+ZQGp 1OLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=oV4yvPzBl+8JFQ4FMZmRE08ppy67MX2UmEYPl8EhO50=; b=YVHMDM4AX/yTrO7cmOtmclMlEqk0duB9LwB4+mKyQ8Xf2azfHTrw6kFvScbZwMFEE0 jmmM1/h2eE/jqVPrr0EJeVPek8CVcd57O1UwXYvY7YgAhAG8PWMpHr0gB7CFjO/Mxxv7 L6N2GVI8dXVm8dNBRDz0YoM66oCZbYdlJ4wUQhoBl21mkZlqQ5FuM/+pwJEEJ5FwbXUI CiAK1sE6ogpwxjyITlYfklkEiaf79UCjW4rBBt18VeDVgQrAopC/2DH6cj/69GNTsNyx 6ipaRf/ZkbROpvGZEnFCvu+0rnHiWRHgGxs4fd/y/Fi14sp1gYOz73WetUt7wv3g2/Y0 xZQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SyCpLMrB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id x22si1785346ejs.326.2021.04.15.03.48.12; Thu, 15 Apr 2021 03:48:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SyCpLMrB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S232299AbhDOKrS (ORCPT + 99 others); Thu, 15 Apr 2021 06:47:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbhDOKrR (ORCPT ); Thu, 15 Apr 2021 06:47:17 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A001C061574; Thu, 15 Apr 2021 03:46:54 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id u15so3276260plf.10; Thu, 15 Apr 2021 03:46:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oV4yvPzBl+8JFQ4FMZmRE08ppy67MX2UmEYPl8EhO50=; b=SyCpLMrBzeb3fwLhDpa8qxrbb//VUgy89Xbxe2C1+tWhCS9enUHbulLBHkcU6OX0y6 aHxwV87N38c/JoUPRfl6OhhKdhUVhou/52XznXoo8Bx5Tu22pxYcEqRVukZs1IfA2tDd lNgirBp+nJPByNqRfO3W2SBS7jyrvI42Y0qbt8PZUL0CXTRAX+Fx3snanIKBTDexZDsV JMY4U2CzQt/F7Xgchoi+hcCzI8t+w7vHQgYlQ3PdPAtg6af3Otr+yAA5x94ts4Y1VodI 7d73jN58s11sK0a6XN+8Ktwxv3EtNqBChHGjI1PBxgR5BmasC3dTi9SFfUzyAvZE1dIV 9Hgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oV4yvPzBl+8JFQ4FMZmRE08ppy67MX2UmEYPl8EhO50=; b=Fq5o1UWfdxpF1762POLCJd1t/b/5zKhCwkWSvoxHUlDrht0BYQcF2wkL2yyd0aEZE+ hGk5HR5GniWqSCF7t7O4msRId6cah/zcI0M9Brxd9Yy5hle9624Jah5l+SektASHEjkG rg0kebCaoYGpsf6eutA3BSWbSgNh+sOXVvjgWrpPwT3TsXT7xpvgTjshKgm0RT8DMNBA FQB8Athrb3slCr9zZkPmWfSB3jBkiDPOfGUefmWFsvijr2S9Ww1QLJTJoylsxIaL4WXe TPvVVDMgvJwuckCWo8PaRyTFuG9TrHvdsouKc1WTYJAbwjq026vybMysWjyoQOcBHTqr shmQ== X-Gm-Message-State: AOAM532vTnG0H5GHpbZBIVMOr29sb5o3OZ4WNrbSBV/gL3fV7Tiumn12 NXSbNZ/Stkw3GWiJIwoliGr7sQEkstNstY1XUs0= X-Received: by 2002:a17:902:264:b029:eb:3d3a:a09c with SMTP id 91-20020a1709020264b02900eb3d3aa09cmr3246929plc.0.1618483613936; Thu, 15 Apr 2021 03:46:53 -0700 (PDT) MIME-Version: 1.0 References: <20210412034712.16778-1-zev@bewilderbeest.net> <20210412034712.16778-4-zev@bewilderbeest.net> In-Reply-To: <20210412034712.16778-4-zev@bewilderbeest.net> From: Andy Shevchenko Date: Thu, 15 Apr 2021 13:46:37 +0300 Message-ID: Subject: Re: [PATCH v6 3/4] serial: 8250_aspeed_vuart: add aspeed,lpc-io-reg and aspeed,lpc-interrupts DT properties To: Zev Weiss Cc: Joel Stanley , OpenBMC Maillist , linux-arm Mailing List , "moderated list:ARM/ASPEED MACHINE SUPPORT" , Linux Kernel Mailing List , Andrew Jeffery , Greg Kroah-Hartman , Jiri Slaby , "open list:SERIAL DRIVERS" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 12, 2021 at 7:05 AM Zev Weiss wrote: > > These allow describing all the Aspeed VUART attributes currently > available via sysfs. aspeed,lpc-interrupts provides a replacement for > the deprecated aspeed,sirq-polarity-sense property. One nit-pick below. In any case it's fine. > Signed-off-by: Zev Weiss > --- > drivers/tty/serial/8250/8250_aspeed_vuart.c | 51 ++++++++++++++++++++- > 1 file changed, 49 insertions(+), 2 deletions(-) > > diff --git a/drivers/tty/serial/8250/8250_aspeed_vuart.c b/drivers/tty/serial/8250/8250_aspeed_vuart.c > index 8433f8dbb186..3c239d98747f 100644 > --- a/drivers/tty/serial/8250/8250_aspeed_vuart.c > +++ b/drivers/tty/serial/8250/8250_aspeed_vuart.c > @@ -28,6 +28,10 @@ > #define ASPEED_VUART_ADDRL 0x28 > #define ASPEED_VUART_ADDRH 0x2c > > +#define ASPEED_VUART_DEFAULT_LPC_ADDR 0x3f8 > +#define ASPEED_VUART_DEFAULT_SIRQ 4 > +#define ASPEED_VUART_DEFAULT_SIRQ_POLARITY IRQ_TYPE_LEVEL_LOW > + > struct aspeed_vuart { > struct device *dev; > void __iomem *regs; > @@ -386,6 +390,18 @@ static void aspeed_vuart_auto_configure_sirq_polarity( > aspeed_vuart_set_sirq_polarity(vuart, (value & reg_mask) == 0); > } > > +static int aspeed_vuart_map_irq_polarity(u32 dt) > +{ > + switch (dt) { > + case IRQ_TYPE_LEVEL_LOW: > + return 0; > + case IRQ_TYPE_LEVEL_HIGH: > + return 1; > + default: > + return -EINVAL; > + } > +} > + > static int aspeed_vuart_probe(struct platform_device *pdev) > { > struct of_phandle_args sirq_polarity_sense_args; > @@ -393,8 +409,8 @@ static int aspeed_vuart_probe(struct platform_device *pdev) > struct aspeed_vuart *vuart; > struct device_node *np; > struct resource *res; > - u32 clk, prop; > - int rc; > + u32 clk, prop, sirq[2]; > + int rc, sirq_polarity; > > np = pdev->dev.of_node; > > @@ -501,6 +517,37 @@ static int aspeed_vuart_probe(struct platform_device *pdev) > of_node_put(sirq_polarity_sense_args.np); > } > > + rc = of_property_read_u32(np, "aspeed,lpc-io-reg", &prop); > + if (rc < 0) > + prop = ASPEED_VUART_DEFAULT_LPC_ADDR; > + > + rc = aspeed_vuart_set_lpc_address(vuart, prop); > + if (rc < 0) { > + dev_err(&pdev->dev, "invalid value in aspeed,lpc-io-reg property\n"); > + goto err_clk_disable; > + } > + > + rc = of_property_read_u32_array(np, "aspeed,lpc-interrupts", sirq, 2); > + if (rc < 0) { > + sirq[0] = ASPEED_VUART_DEFAULT_SIRQ; > + sirq[1] = ASPEED_VUART_DEFAULT_SIRQ_POLARITY; > + } > + > + rc = aspeed_vuart_set_sirq(vuart, sirq[0]); > + if (rc < 0) { > + dev_err(&pdev->dev, "invalid sirq number in aspeed,lpc-interrupts property\n"); > + goto err_clk_disable; > + } > + > + sirq_polarity = aspeed_vuart_map_irq_polarity(sirq[1]); > + if (sirq_polarity < 0) { > + dev_err(&pdev->dev, "invalid sirq polarity in aspeed,lpc-interrupts property\n"); > + rc = sirq_polarity; > + goto err_clk_disable; > + } Why not to use the same pattern as above, i.e. rc = aspeed_vuart_map_irq_polarity(sirq[1]); if (rc < 0) { dev_err(&pdev->dev, "invalid sirq polarity in aspeed,lpc-interrupts property\n"); goto err_clk_disable; } sirq_polarity = rc; ? > + aspeed_vuart_set_sirq_polarity(vuart, sirq_polarity); > + > aspeed_vuart_set_enabled(vuart, true); > aspeed_vuart_set_host_tx_discard(vuart, true); > platform_set_drvdata(pdev, vuart); -- With Best Regards, Andy Shevchenko