Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6062007rwr; Mon, 24 Apr 2023 13:07:06 -0700 (PDT) X-Google-Smtp-Source: AKy350b8d7ayMWPyvQ5ud9taZKm8YHJu2fmZANeGl3qwuiJ2Wu5VVfiAvHDbwGXplFQTQsbFSRqf X-Received: by 2002:a17:903:2441:b0:1a0:50bd:31a8 with SMTP id l1-20020a170903244100b001a050bd31a8mr19227330pls.26.1682366825350; Mon, 24 Apr 2023 13:07:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682366825; cv=none; d=google.com; s=arc-20160816; b=vH+DsOpwPOkqCBfhX6d/U0K5YxWprxxzcTBWK+F2gAH6P5uWs6o3OGRG6g48uSFT2S VoP45wm6Q7ECZPs0X+dAEdIGVUpj/YSrg6Tv+cjl0IdxotuESOWuOwEdReMH+bntBY9t dAokhjuQb56S3+oypoiatN/tZwUwyaIGJ4P3Qnwe+DIEEyF0yBAh492pEDh9dPUWi6Bg TG/ak82+RilKXXPUb1KiZZoLzPQI6nOqYwkEIeRpabUngMF81keP/lL2B8j5J74ACivW e5x4O8On4vbVcwlNemg75dtaUn45eKmXBfm5++7/iv+RYOAa3HSR1crTSTWF4uji+W3K t9Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=t3Kjwisra9fRkJJQf4cBtKFByKMHw0+JdaUWtNfIjA4=; b=w1JdW/EZky7zbJxp/AuL0ALa5CNc+9fjcV4uW0AqAqZMynhW2ZJojGzSQUHnEpowih tWHIrEw1+m6ufjj45LkO1cDkidClDlxmuqKjDdyj7qMRdJ9FcFZZtbbLbmN/7OVWUUYe D6X0wTXzA4yBxHTjTue373k2+4flasC5Udn+AZBdYRDBAnvcuVxIa/39ERXut+YIhBpe PzVeEjBmolesGgcmGw5mnJkR99tzmsf3mmAdQVt2hLk2cLEcuBxipHbKH3+hF36eAxzo gBRlxuwr6j4AH2Eg5OplrzI2mhMyOTiF8fI3lrW71v32buVWo5kjQTxLU4uHk7ViRVH+ HNsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id np17-20020a17090b4c5100b0024792a548dbsi15681278pjb.126.2023.04.24.13.06.53; Mon, 24 Apr 2023 13:07:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231716AbjDXUDL (ORCPT + 99 others); Mon, 24 Apr 2023 16:03:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232253AbjDXUDK (ORCPT ); Mon, 24 Apr 2023 16:03:10 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D498E1 for ; Mon, 24 Apr 2023 13:03:09 -0700 (PDT) Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pr2Ol-0008E0-El; Mon, 24 Apr 2023 22:02:55 +0200 Received: from pza by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1pr2Oj-0004R7-Ph; Mon, 24 Apr 2023 22:02:53 +0200 Date: Mon, 24 Apr 2023 22:02:53 +0200 From: Philipp Zabel To: Jacky Huang Cc: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, lee@kernel.org, mturquette@baylibre.com, sboyd@kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, devicetree@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, arnd@arndb.de, schung@nuvoton.com, mjchen@nuvoton.com, Jacky Huang Subject: Re: [PATCH v6 10/12] reset: Add Nuvoton ma35d1 reset driver support Message-ID: <20230424200253.GC30248@pengutronix.de> References: <20230328021912.177301-1-ychuang570808@gmail.com> <20230328021912.177301-11-ychuang570808@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230328021912.177301-11-ychuang570808@gmail.com> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-Accept-Language: de,en X-Accept-Content-Type: text/plain User-Agent: Mutt/1.10.1 (2018-07-13) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: pza@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jacky, On Tue, Mar 28, 2023 at 02:19:10AM +0000, Jacky Huang wrote: > From: Jacky Huang > > This driver supports individual IP reset for ma35d1. The reset > control registers is a subset of system control registers. > > Signed-off-by: Jacky Huang > --- > drivers/reset/Kconfig | 6 ++ > drivers/reset/Makefile | 1 + > drivers/reset/reset-ma35d1.c | 152 +++++++++++++++++++++++++++++++++++ > 3 files changed, 159 insertions(+) > create mode 100644 drivers/reset/reset-ma35d1.c > [...] > diff --git a/drivers/reset/reset-ma35d1.c b/drivers/reset/reset-ma35d1.c > new file mode 100644 > index 000000000000..221299e7b873 > --- /dev/null > +++ b/drivers/reset/reset-ma35d1.c > @@ -0,0 +1,152 @@ [...] > +static int ma35d1_reset_update(struct reset_controller_dev *rcdev, > + unsigned long id, bool assert) > +{ > + unsigned int reg; > + int ret; > + int offset = (id / RST_PRE_REG) * 4; > + struct ma35d1_reset_data *data = > + container_of(rcdev, struct ma35d1_reset_data, rcdev); > + > + ret = regmap_read(data->regmap, REG_SYS_IPRST0 + offset, ®); > + if (ret < 0) > + return ret; > + if (assert) > + reg |= 1 << (id % RST_PRE_REG); > + else > + reg &= ~(1 << (id % RST_PRE_REG)); > + > + return regmap_write(data->regmap, REG_SYS_IPRST0 + offset, reg); This should use regmap_update_bits(). [...] > +static int ma35d1_reset_status(struct reset_controller_dev *rcdev, > + unsigned long id) > +{ > + int reg, ret; > + int offset = id / RST_PRE_REG; Should this be int offset = (id / RST_PRE_REG) * 4; ? > +static int ma35d1_reset_probe(struct platform_device *pdev) > +{ > + int err; > + struct device *dev = &pdev->dev; > + struct device_node *parent; > + struct ma35d1_reset_data *reset_data; > + struct ma35d1_reboot_data *reboot_data; > + > + if (!pdev->dev.of_node) { > + dev_err(&pdev->dev, "Device tree node not found\n"); > + return -EINVAL; > + } > + > + reset_data = devm_kzalloc(dev, sizeof(*reset_data), GFP_KERNEL); > + if (!reset_data) > + return -ENOMEM; > + > + reboot_data = devm_kzalloc(dev, sizeof(*reboot_data), GFP_KERNEL); > + if (!reboot_data) > + return -ENOMEM; These structures could be combined into one. regards Philipp