Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2469956rwe; Sun, 28 Aug 2022 12:23:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR4Ewl8p0YDEbkkuvpvuf3eKOWW6Y5EOilunEfHb2eZt4EdwEJaJuAzY+pORahUaM1gu1ouZ X-Received: by 2002:a17:90a:d585:b0:1f4:f9a5:22a9 with SMTP id v5-20020a17090ad58500b001f4f9a522a9mr15139902pju.49.1661714621605; Sun, 28 Aug 2022 12:23:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661714621; cv=none; d=google.com; s=arc-20160816; b=jMcUYHGdvujV8dBiNEMLUhnU4j9mOX07TweHIAXNgfGuxC4yZ822HBLQ1O0C4kNcjE aHlxDZYkILBYpRFiCP6yEumEdlGH6y5KfN6X1BWZDo4YOCw7pCEHDfvm7OFFr1z83E1C sCG6vrWSMwAOz4XbvFYXVn1/GZEIt5A/ho/zHr9k5hu9hFcw0DN2j65POXuca3EAKyEY oK+9EGOOtjRj1McBN++f84TwJVV6ygFWSjh8usXpOKjsv6c/xYH6YTfeLZSt0EauEk0f /qqfBbk+M6OozHNRasiQ30r5UOKZ8dM/gt7v7SJnorDh06uKC4H4F0Wn0yj0ZnmykJiw VQ9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=NN0hANgOTosS67AZM7qStNdWjz7PM0mNu/rAh+RRKaQ=; b=xBKBESnx1kqDo28OpHntxW5n9NaD+jn7uCAkXz1mP3MXU06ptQx9w9EisZAxBXLvZj PW3DcVFkZYZtLv/BucQEDp+EhIRYa5gVCsfrNYlpLblgnAgF/SlKR/RyY4vc59yLHt0B lS7F9X476e3VBKEaApvQCwnO7ubLp2cUuCXoJLpRYYMMo5F8Nojf3My3FYNobyCIEuQL ZsSjvMGm9/4esqqp2hy4jUpL6dxAmSHs9TcWtiyjpFN1xdd4aRmyftoFI0t0nsufRfn2 pY0VQZ/o1gjZ8qFYNZWA90Cc5pg0KiiWxiUcd2x2hyUHLZTgodXl3F0qKosZ9ytGzIbd i2Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=c20v2l0I; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y19-20020a17090abd1300b001f59204dd5esi7165975pjr.48.2022.08.28.12.23.31; Sun, 28 Aug 2022 12:23:41 -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; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=c20v2l0I; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230142AbiH1TWW (ORCPT + 99 others); Sun, 28 Aug 2022 15:22:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230103AbiH1TWQ (ORCPT ); Sun, 28 Aug 2022 15:22:16 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB302248EF; Sun, 28 Aug 2022 12:22:12 -0700 (PDT) Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27SJLwXD032638; Sun, 28 Aug 2022 19:21:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=NN0hANgOTosS67AZM7qStNdWjz7PM0mNu/rAh+RRKaQ=; b=c20v2l0I3wZcgXrfyR4lhPmpwpxFAfVpA01wBfxCHanQuOqGek80nyz2aXhHavjZZdNR hMRCtsNBskc8jVPQMB+zDm383RRDclzOTtz9WZMdW/Tc2DGc0Ckt9IrV9pva8t0EIIaS BB3aCcunmAtSL/1JLeeIw5TC2g/ZW1A6wrVddFDnaLHqBhqgjreCAV6eeD+r4CZ3ZWNn vvuEPKU7YxiiKayQvc16NS6jOH7YUv4WEr2ikosGc15GhhpxNWjm0uEcCwFSDIr1gGMc 7V8ULSQ2QArEFDWPH73DnhFdox4k50p2vbd60TvEA5g63RQ4xigs2k45hE5spPPof8df bw== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3j7bndttd4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 28 Aug 2022 19:21:57 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 27SJLu3k016820 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 28 Aug 2022 19:21:56 GMT Received: from hyd-lnxbld559.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Sun, 28 Aug 2022 12:21:51 -0700 From: Akhil P Oommen To: freedreno , , , Rob Clark , Bjorn Andersson , "Stephen Boyd" , Dmitry Baryshkov CC: , Douglas Anderson , Akhil P Oommen , "Andy Gross" , Konrad Dybcio , Michael Turquette , Stephen Boyd , , Subject: [PATCH v5 2/6] clk: qcom: Allow custom reset ops Date: Mon, 29 Aug 2022 00:51:15 +0530 Message-ID: <20220829005035.v5.2.I75baff799a363bbb960376539e3a0f737377c3f1@changeid> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1661714479-28981-1-git-send-email-quic_akhilpo@quicinc.com> References: <1661714479-28981-1-git-send-email-quic_akhilpo@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: bLq1jTHRB1vL9LkUNhTCNjRFP9BZlQzD X-Proofpoint-ORIG-GUID: bLq1jTHRB1vL9LkUNhTCNjRFP9BZlQzD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-28_12,2022-08-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1015 mlxscore=0 malwarescore=0 bulkscore=0 impostorscore=0 mlxlogscore=999 lowpriorityscore=0 priorityscore=1501 spamscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208280080 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Allow soc specific clk drivers to specify a custom reset operation. We will use this in an upcoming patch to allow gpucc driver to specify a differet reset operation for cx_gdsc. Signed-off-by: Akhil P Oommen Reviewed-by: Dmitry Baryshkov --- (no changes since v3) Changes in v3: - Use pointer to const for "struct qcom_reset_ops" in qcom_reset_map (Krzysztof) Changes in v2: - Return error when a particular custom reset op is not implemented. (Dmitry) drivers/clk/qcom/reset.c | 27 +++++++++++++++++++++++++++ drivers/clk/qcom/reset.h | 8 ++++++++ 2 files changed, 35 insertions(+) diff --git a/drivers/clk/qcom/reset.c b/drivers/clk/qcom/reset.c index 819d194..b7ae4a3 100644 --- a/drivers/clk/qcom/reset.c +++ b/drivers/clk/qcom/reset.c @@ -13,6 +13,21 @@ static int qcom_reset(struct reset_controller_dev *rcdev, unsigned long id) { + struct qcom_reset_controller *rst; + const struct qcom_reset_map *map; + + rst = to_qcom_reset_controller(rcdev); + map = &rst->reset_map[id]; + + if (map->ops && map->ops->reset) + return map->ops->reset(map->priv); + /* + * If custom ops is implemented but just not this callback, return + * error + */ + else if (map->ops) + return -EOPNOTSUPP; + rcdev->ops->assert(rcdev, id); udelay(1); rcdev->ops->deassert(rcdev, id); @@ -28,6 +43,12 @@ qcom_reset_assert(struct reset_controller_dev *rcdev, unsigned long id) rst = to_qcom_reset_controller(rcdev); map = &rst->reset_map[id]; + + if (map->ops && map->ops->assert) + return map->ops->assert(map->priv); + else if (map->ops) + return -EOPNOTSUPP; + mask = BIT(map->bit); return regmap_update_bits(rst->regmap, map->reg, mask, mask); @@ -42,6 +63,12 @@ qcom_reset_deassert(struct reset_controller_dev *rcdev, unsigned long id) rst = to_qcom_reset_controller(rcdev); map = &rst->reset_map[id]; + + if (map->ops && map->ops->deassert) + return map->ops->deassert(map->priv); + else if (map->ops) + return -EOPNOTSUPP; + mask = BIT(map->bit); return regmap_update_bits(rst->regmap, map->reg, mask, 0); diff --git a/drivers/clk/qcom/reset.h b/drivers/clk/qcom/reset.h index 2a08b5e..f3147eb 100644 --- a/drivers/clk/qcom/reset.h +++ b/drivers/clk/qcom/reset.h @@ -8,9 +8,17 @@ #include +struct qcom_reset_ops { + int (*reset)(void *priv); + int (*assert)(void *priv); + int (*deassert)(void *priv); +}; + struct qcom_reset_map { unsigned int reg; u8 bit; + const struct qcom_reset_ops *ops; + void *priv; }; struct regmap; -- 2.7.4