Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp699251lqb; Fri, 15 Mar 2024 04:13:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX0xh+RuTKru1X055jIP9TX8RDISubwa8+gRwqQUyWw4S6Ug3ivm/wT9E6dJuPslW/HSz6WLt+AQns4/DMW2AUQvy7MkoAqV7xlevEeQw== X-Google-Smtp-Source: AGHT+IH9/Whl5ErHa8Baw6wihiRYW/SWEZo8uYc+zYJkfu8X8lLxqquhxr3KDbJeFRB4bYf5HSjZ X-Received: by 2002:a17:90b:788:b0:29c:844:a91 with SMTP id l8-20020a17090b078800b0029c08440a91mr2622367pjz.48.1710501181311; Fri, 15 Mar 2024 04:13:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710501181; cv=pass; d=google.com; s=arc-20160816; b=mxXw6nNLThTav63YCNg8Ul1SauWIxT4/0W+fvTCJITWRQf6LEsuapyAA44EHTr+I8J Fx/LxjSvg/+d/uELxS7d0AbcRkqSHHxORgKs3wZwWXBDx+IHWaoGS5H8sP0YaRS/5S3H v8zScY5aE3hy03YESXtwt6KvSWlB+uehJr5ZjQdR/mGyoiqbD4jSsJjnbdWFTgCpcFEg yvvTy7S3QF7GgTwXJSXt70MRWfMr1ZUp4x8+P5d6L5Ew1zfucC0zu05eMoAFTQ8xkmLm ZgDoxDT2olAobimWAL9ELuOIlMdrj89HZFPTp84e5Hi+NK79qnxz9OeYJ+V8WKanTCjB xteQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=3WRWjvvnp9p2Zrdwm/DvbGS2GHs3yCuEkFQCDDVdNqk=; fh=x0TgoAxpWhsHeGJlUNXKeTIk28FLTKexZ/W8TOUom3M=; b=S/KAtKhDig3h8JS8r8y+Ity6nBERdEnrSHzIayOsoqSME7idIemUMVXXv37Xp8eQ8i G1RcO6qNPYLcCgBjHH/l85mR3ZhPXGO3h45GZSsQDlxV//8Wrx8CV7hwzvl6S9u6SBJT ixAZc2eJt2hYdRLNKJpUopgerpbd8jGuIjc0Oh6e1qWgB5LGaSqKjzFn/8So3HMpgy3D XejJASVeiBOmtow87MMKd5stfLc2QPh74OeZuICWQ0kbAsfrZXUfZVbsnY9KgKBKxRs4 OAINPvo13aA1vQFdoshwIcrUtfugKRcv75uLwN4g1q54IlPnm+hJ0bO8JqXoprnEE8uN SS5A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=BmECyPL9; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-104306-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104306-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id iz21-20020a17090ae79500b0029c6179fdddsi2467640pjb.152.2024.03.15.04.13.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 04:13:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-104306-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=BmECyPL9; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-104306-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104306-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 915C3283F72 for ; Fri, 15 Mar 2024 11:12:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7A2191BDEB; Fri, 15 Mar 2024 11:11:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="BmECyPL9" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB6AE1BDE7; Fri, 15 Mar 2024 11:11:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710501103; cv=none; b=Bnd9MvNC+r9DgY4dVpGyJKD9gf7iJLO7aW4D7sUjwm8cQMrhYNOXWH7fmW5kb76YggSl3OHPqPcCUhfgTEnCIsRScq6jdtVKlcuT0iD3x8fymemhdSAEtx9jP7wIRn5C73nKGw4kOucg+0JU25hvFY0bXkt6rLDjyKI3s5xIDEk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710501103; c=relaxed/simple; bh=e/rGuNSJzv1yD61uy/MiTX1UVvRLnNMQOFemqza0JhA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=U6LkliJrhjF+v+gGlwFnIh834mqKCIkm+yWLR+AGeuGe/G42cuer2D/3G0aYmosXsjwL/GYNXL/Q9wuHsAPWYj/MrCLiqLsSeYbz3rUfl7CbO7rHQwyMLJ+A8ko3ndqclOtyh8dY7vt2/29dAoF//sfZwED/o/6jMkwpHfvhWts= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=BmECyPL9; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42F9ea1D016562; Fri, 15 Mar 2024 11:11:34 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-transfer-encoding:content-type; s= qcppdkim1; bh=3WRWjvvnp9p2Zrdwm/DvbGS2GHs3yCuEkFQCDDVdNqk=; b=Bm ECyPL9ufUV0CLAwKi3WavZ3Ev32aZ0z2jtUtQ6e+WFd4TiaFzEvFsiIhCf6QOfJO HHfyKeWwkxezIvqPb+NoUXmOcgPURCt9pXDGXPH0O/bn+EVXil/NNjCsosVluyCx cj1Lvl1PMCCCyRKGSLpgodHr3pcXSIEgVMa5xKSh5r3YG5ApQkPGljOKoLv4CpWv i/8lv1tAXTXbQyn9tHgJpYA1fROTzfnvRovEH4ryVxWB04T6ruEL8NoBf7JzFleZ 4Ozm0aZlvzVfnBux+T4K3K0MFTQE+wxQiFPEtQvKU8pwMSeg1UVGnGtWoNDcgNNH pVTRCyONi5+jLUdiQnww== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3wva0612pa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Mar 2024 11:11:34 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 42FBBXMo000412 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Mar 2024 11:11:33 GMT Received: from hu-jkona-hyd.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.1118.40; Fri, 15 Mar 2024 04:11:25 -0700 From: Jagadeesh Kona To: "Rafael J . Wysocki" , Kevin Hilman , Ulf Hansson , Pavel Machek , Len Brown , Greg Kroah-Hartman , Bjorn Andersson , "Konrad Dybcio" , Michael Turquette , Andy Gross , Stephen Boyd , Stanimir Varbanov , "Vikash Garodia" , Bryan O'Donoghue , Mauro Carvalho Chehab , Dmitry Baryshkov , Abel Vesa , Taniya Das CC: , , , , , Jagadeesh Kona , "Imran Shaik" , Ajit Pandey Subject: [PATCH V5 3/5] clk: qcom: gdsc: Add set and get hwmode callbacks to switch GDSC mode Date: Fri, 15 Mar 2024 16:40:44 +0530 Message-ID: <20240315111046.22136-4-quic_jkona@quicinc.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240315111046.22136-1-quic_jkona@quicinc.com> References: <20240315111046.22136-1-quic_jkona@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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: q_ryKBSGW4BB8wGPsIRzMlfC46y3V8NZ X-Proofpoint-ORIG-GUID: q_ryKBSGW4BB8wGPsIRzMlfC46y3V8NZ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-14_13,2024-03-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 impostorscore=0 spamscore=0 phishscore=0 lowpriorityscore=0 suspectscore=0 malwarescore=0 clxscore=1015 priorityscore=1501 mlxscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2403140001 definitions=main-2403150091 Some GDSC client drivers require the GDSC mode to be switched dynamically to HW mode at runtime to gain the power benefits. Typically such client drivers require the GDSC to be brought up in SW mode initially to enable the required dependent clocks and configure the hardware to proper state. Once initial hardware set up is done, they switch the GDSC to HW mode to save power. At the end of usecase, they switch the GDSC back to SW mode and disable the GDSC. Introduce HW_CTRL_TRIGGER flag to register the set_hwmode_dev and get_hwmode_dev callbacks for GDSC's whose respective client drivers require the GDSC mode to be switched dynamically at runtime using dev_pm_genpd_set_hwmode() API. Signed-off-by: Jagadeesh Kona Signed-off-by: Abel Vesa --- drivers/clk/qcom/gdsc.c | 37 +++++++++++++++++++++++++++++++++++++ drivers/clk/qcom/gdsc.h | 1 + 2 files changed, 38 insertions(+) diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c index e7a4068b9f39..0d64af176542 100644 --- a/drivers/clk/qcom/gdsc.c +++ b/drivers/clk/qcom/gdsc.c @@ -363,6 +363,39 @@ static int gdsc_disable(struct generic_pm_domain *domain) return 0; } +static int gdsc_set_hwmode(struct generic_pm_domain *domain, struct device *dev, bool mode) +{ + struct gdsc *sc = domain_to_gdsc(domain); + int ret; + + ret = gdsc_hwctrl(sc, mode); + if (ret) + return ret; + + /* Wait for 1usec for mode transition to properly complete */ + udelay(1); + + /* + * When GDSC is switched to HW mode, HW can disable the GDSC. + * When GDSC is switched back to SW mode, the GDSC will be enabled + * again, hence need to poll for GDSC to complete the power up. + */ + if (!mode) + return gdsc_poll_status(sc, GDSC_ON); + + return 0; +} + +static bool gdsc_get_hwmode(struct generic_pm_domain *domain, struct device *dev) +{ + struct gdsc *sc = domain_to_gdsc(domain); + u32 val; + + regmap_read(sc->regmap, sc->gdscr, &val); + + return !!(val & HW_CONTROL_MASK); +} + static int gdsc_init(struct gdsc *sc) { u32 mask, val; @@ -451,6 +484,10 @@ static int gdsc_init(struct gdsc *sc) sc->pd.power_off = gdsc_disable; if (!sc->pd.power_on) sc->pd.power_on = gdsc_enable; + if (sc->flags & HW_CTRL_TRIGGER) { + sc->pd.set_hwmode_dev = gdsc_set_hwmode; + sc->pd.get_hwmode_dev = gdsc_get_hwmode; + } ret = pm_genpd_init(&sc->pd, NULL, !on); if (ret) diff --git a/drivers/clk/qcom/gdsc.h b/drivers/clk/qcom/gdsc.h index 803512688336..1e2779b823d1 100644 --- a/drivers/clk/qcom/gdsc.h +++ b/drivers/clk/qcom/gdsc.h @@ -67,6 +67,7 @@ struct gdsc { #define ALWAYS_ON BIT(6) #define RETAIN_FF_ENABLE BIT(7) #define NO_RET_PERIPH BIT(8) +#define HW_CTRL_TRIGGER BIT(9) struct reset_controller_dev *rcdev; unsigned int *resets; unsigned int reset_count; -- 2.43.0