Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp126567pxk; Wed, 2 Sep 2020 16:45:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdeD8SmmmOA/Aae4zFQBrJLwofw9P4vwT3tG8I9OyH5LW8b0pZ7ELQbm68yhmtlf8kzkN6 X-Received: by 2002:a17:906:fa81:: with SMTP id lt1mr506781ejb.459.1599090344597; Wed, 02 Sep 2020 16:45:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599090344; cv=none; d=google.com; s=arc-20160816; b=zEc0cqu2OW90oQ18Zvm8RMW8kPUgyK/lv2ShCA+PLlR2wnRI1ew2W7LnpYfdpurivO kz9o5PofGeG78Yrl9O4e5cuSYJFe6/Byrzo0B2z2AAHaR6/a4tNpAfzYgdK2+bxeZDCW nXln2w1RNKJxNxL/abiTQCb12bi385kLDD21HxDj/dcR9Y397wTQ2wIWkQTCtPfdpLwg 2yA6OnpQU7+u7Jw3DBnfrdlTeDUi2KtCpK/vSgl2brknpmps3/5yhqoaOTsA5rO9i6TU guP5k9tjAPhgNfs3R0GujlrUKKrcBror91rgMMqU12t2/JOLj1Zmy7a+EpBRa/b6JwSC haog== 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; bh=BFbzFeJpfcaC6ycaf4eZClFigSVdESVAB5glK64fSDw=; b=OJsB2qpURqYuKR5nN+exaAmvftggdsq+uREm6mqowJD4DuBa9EtArdb34OHXyRHOyW MMrqBInJFebiwnoKn4d3fMPGVxw8D/7Ycnofkmtq1s/x7rs9PEKo12SRVaVUzqLdnybL NnEOl0STFI/u8SRTJhrB9RIdVYzrUJgYco6JBcdD8t/FKrroCln7yC3yQoygyqRRIFF0 Pzv/52D4QCVpbuaET+6Ft/tCgFRACaUvHxOuFDgFvdqljDxc91YqlE9n+QriKw7LdeWF fquEdMidomJCQAxdD6GXK2aoRBa+3R38PDdGVcMo3SH117VKxWMwyK3MlW9ksLH/G53K RYBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=DXxDiC6z; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b19si560412edn.421.2020.09.02.16.45.04; Wed, 02 Sep 2020 16:45:44 -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=@ti.com header.s=ti-com-17Q1 header.b=DXxDiC6z; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726528AbgIBXko (ORCPT + 99 others); Wed, 2 Sep 2020 19:40:44 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:58268 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726310AbgIBXko (ORCPT ); Wed, 2 Sep 2020 19:40:44 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 082NeUfk061757; Wed, 2 Sep 2020 18:40:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1599090030; bh=BFbzFeJpfcaC6ycaf4eZClFigSVdESVAB5glK64fSDw=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=DXxDiC6zHHq3/4GkD5eKFXhhia0zcyCk6W9P2W7ahuO56qpqpRtTnwP4Wv3T0Irsi orCV1XB9pxji1b3LegMI8OO9432U5YNH0JeIZnS/7BnOPlSiwIXvRufYKvjg7FQP/A 0Po+cNMcrA6g3+Jmh34JsJo+Gf9bdynE17JtAhzM= Received: from DLEE102.ent.ti.com (dlee102.ent.ti.com [157.170.170.32]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 082NeUX1040689 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 2 Sep 2020 18:40:30 -0500 Received: from DLEE108.ent.ti.com (157.170.170.38) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Wed, 2 Sep 2020 18:40:29 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Wed, 2 Sep 2020 18:40:29 -0500 Received: from [10.250.34.112] (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 082NeTBX025309; Wed, 2 Sep 2020 18:40:29 -0500 Subject: Re: [v4,3/4] reset-controller: ti: introduce a new reset handler To: Crystal Guo , , , CC: , , , , , , , , , References: <20200817030324.5690-1-crystal.guo@mediatek.com> <20200817030324.5690-4-crystal.guo@mediatek.com> From: Suman Anna Message-ID: <3a5decee-5f31-e27d-a120-1f835241a87c@ti.com> Date: Wed, 2 Sep 2020 18:40:24 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200817030324.5690-4-crystal.guo@mediatek.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Crystal, On 8/16/20 10:03 PM, Crystal Guo wrote: > Introduce ti_syscon_reset() to integrate assert and deassert together. > If some modules need do serialized assert and deassert operations > to reset itself, reset_control_reset can be called for convenience. There are multiple changes in this same patch. I think you should split this functionality away from the change for the regmap_update_bits() to regmap_write_bits(), similar to what you have done in your v2 Patch 4. > > Such as reset-qcom-aoss.c, it integrates assert and deassert together > by 'reset' method. MTK Socs also need this method to perform reset. > > Signed-off-by: Crystal Guo > --- > drivers/reset/reset-ti-syscon.c | 26 ++++++++++++++++++++++++-- > 1 file changed, 24 insertions(+), 2 deletions(-) > > diff --git a/drivers/reset/reset-ti-syscon.c b/drivers/reset/reset-ti-syscon.c > index a2635c21db7f..08289342f9af 100644 > --- a/drivers/reset/reset-ti-syscon.c > +++ b/drivers/reset/reset-ti-syscon.c > @@ -15,6 +15,7 @@ > * GNU General Public License for more details. > */ > > +#include > #include > #include > #include > @@ -56,6 +57,7 @@ struct ti_syscon_reset_data { > struct regmap *regmap; > struct ti_syscon_reset_control *controls; > unsigned int nr_controls; > + unsigned int reset_duration_us; > }; > > #define to_ti_syscon_reset_data(rcdev) \ > @@ -89,7 +91,7 @@ static int ti_syscon_reset_assert(struct reset_controller_dev *rcdev, > mask = BIT(control->assert_bit); > value = (control->flags & ASSERT_SET) ? mask : 0x0; > > - return regmap_update_bits(data->regmap, control->assert_offset, mask, value); > + return regmap_write_bits(data->regmap, control->assert_offset, mask, value); > } > > /** > @@ -120,7 +122,7 @@ static int ti_syscon_reset_deassert(struct reset_controller_dev *rcdev, > mask = BIT(control->deassert_bit); > value = (control->flags & DEASSERT_SET) ? mask : 0x0; > > - return regmap_update_bits(data->regmap, control->deassert_offset, mask, value); > + return regmap_write_bits(data->regmap, control->deassert_offset, mask, value); > } > > /** > @@ -158,9 +160,26 @@ static int ti_syscon_reset_status(struct reset_controller_dev *rcdev, > !(control->flags & STATUS_SET); > } > > +static int ti_syscon_reset(struct reset_controller_dev *rcdev, > + unsigned long id) > +{ > + struct ti_syscon_reset_data *data = to_ti_syscon_reset_data(rcdev); > + int ret; > + > + ret = ti_syscon_reset_assert(rcdev, id); > + if (ret) > + return ret; > + > + if (data->reset_duration_us) > + usleep_range(data->reset_duration_us, data->reset_duration_us * 2); > + > + return ti_syscon_reset_deassert(rcdev, id); I echo Philipp's comments [1] from your original v1 series about this. We don't need a property to distinguish this, but you could add a flag using match data and Mediatek compatible, and use that within this function, or optionally set this ops based on compatible (whatever is preferred by Philipp). regards Suman [1] https://patchwork.kernel.org/comment/23519193/ > +} > + > static const struct reset_control_ops ti_syscon_reset_ops = { > .assert = ti_syscon_reset_assert, > .deassert = ti_syscon_reset_deassert, > + .reset = ti_syscon_reset, > .status = ti_syscon_reset_status, > }; > > @@ -204,6 +223,9 @@ static int ti_syscon_reset_probe(struct platform_device *pdev) > controls[i].flags = be32_to_cpup(list++); > } > > + of_property_read_u32(pdev->dev.of_node, "reset-duration-us", > + &data->reset_duration_us); > + > data->rcdev.ops = &ti_syscon_reset_ops; > data->rcdev.owner = THIS_MODULE; > data->rcdev.of_node = np; >