Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp555190lqp; Sat, 13 Apr 2024 08:22:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU7rS5tPfGaTlo8HgTDUGMdvZv8xCxQHSF1gmC8mK2fA1MwLE7SzyApKUZqVqEMoi2pRh3i0oj/YYQPUh5SBHys3v8vSHjFPXmzcO73Pw== X-Google-Smtp-Source: AGHT+IErqk6+pcQlVkelQrfyMJIRWUwLoWyAfBol+7MTUgcA4hphSGSvO96rwlb2wWbWE2r5Ufxd X-Received: by 2002:a05:6e02:168b:b0:36a:2adb:fd7a with SMTP id f11-20020a056e02168b00b0036a2adbfd7amr6320212ila.30.1713021779575; Sat, 13 Apr 2024 08:22:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713021779; cv=pass; d=google.com; s=arc-20160816; b=dciX1fwwWy/z0QJjDnPToC7+ka+S17chliYi3e2sB6yYefIafEDQ2onPhK6Uk/1GR2 M9wxwg1Zh4Ek8nv5tvHH9f+efBP6tlomi70MpmH1Ng/xnXNIm7e6SKuNt8vwoZ3bW/xB wBh2j5whfkdd7cQv1CTXUo06VEPkQUblqc6XRyZrsBuDL4Zoo8zYRhxfxIIIGYh1LKhn LmODm9v66ddkmefvwBpmdUILrFH6xfPl+ubm/KgAeOH+qkzIqJNQLiN86B+XG4Nou1fV E1Hlh+f6JACfop0uMFec726g004qIUU2flRU5c/jz0BHiOrG4dzVmLqMLN3AhZh4y52K 5W5g== 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=vGFkT1jLAZGFxQ/dkORMXmbS2ozuVVyl+8ASKbyrJS0=; fh=wrxSomcxoiFWVmIn1fJc14tD+OFis3gtUA2aL4mx3Xo=; b=HTabT91v3OIH9ftoj4Ym3xGkyakfQf4uqSNedBtucbH90aBvPyRfKNePkPUvuHzqjB lo//e/oPgiFvyUG++50hkqFQsGlMkHGd5Daok5IUuCeR41bMw/XM8IpKYTdrmCgH1T70 JIiT8tObpUHwoGJUznT5z/TN08KEbLa6J14ytZky0PE4S7GvfAYZgh3vXH7t+iEwG9hE a0pYTU/qqiwEHgTOc+DYvvcB4WkddelrkyE5UcfvDlirMTbwdEAsaQYslvQBijhx4RGb V5G1M35BiIu/RZzDpnfxbBNemSZX7LSBFuX2DNp8+lIJKe3SzON73mISPpAmZpw3ZwzJ OkWQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=ZWXQm1Hs; 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-143777-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143777-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 5-20020a631945000000b005ce06ca3538si5030615pgz.873.2024.04.13.08.22.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Apr 2024 08:22:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-143777-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=ZWXQm1Hs; 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-143777-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143777-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 2E12D281C63 for ; Sat, 13 Apr 2024 15:22:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4472354668; Sat, 13 Apr 2024 15:21:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="ZWXQm1Hs" Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 D88071AAC4; Sat, 13 Apr 2024 15:21:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713021704; cv=none; b=eetDXlgvcWbgLZxZuj0xEjdm4EL8iglvt6TcdikOUkHLgx1bGNBZSLOen7csvYBJdI/T0kWalDo76hx0AXoqiytKJ7B61E29iAKHCNrt6CDxzs5HWPsRMSrej173XOx+tfTAlCPhOChEHavBAfO/6XZ/48WaBv47z5P+N3jglCo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713021704; c=relaxed/simple; bh=l9AiGUYR06ith94hYNURsNBicJturfR2mRvwyn7HrXo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RaaywR1eRFFvOJkb4/C73v73I/t6Fx14HNM/TPrX8x2zCG58Tf5GLNFp8/NZe7LdjfsNZMbsn10cJwORIZiIq5AwbqmUqlq6qQKstR7pAIv7R1Hxjdl6oCh3N91ETsteSnPaw0hXJYFFM/l7lQ3K1k1rBGg2x+B0v4wmQLcnK14= 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=ZWXQm1Hs; arc=none smtp.client-ip=205.220.168.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 (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 43DEuZJp012977; Sat, 13 Apr 2024 15:21:33 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=vGFkT1jLAZGFxQ/dkORMXmbS2ozuVVyl+8ASKbyrJS0=; b=ZW XQm1HsFeWpB43mfZ5/0GwHP8LNAolToKFiQ6mhAKi5Lach7n0ixP0mJ1NhViaukZ SQVIdZCUIy2kLwD5/oWCe4hyw1FQB/xJkIa6mLRG+ZYaeTJ8Qt3C5C2GC1KxJBsR ry2LdoEI1j5+Av6mJ/fMP7+lsVSrRlE/bv1HtN9EiuA+POfyjkIYo8EtDEhNY655 K0SrvbSOQTKTJz63XE9zhqQ/ehBRI6jlJA2ZLaRjQxxKYmheTtQde6em6ezbmS8V fvcUiZ236wR1qvMawT+NT7mPIl8l344ayxx/tBAJjpD/b5Gr8pGGAHGk9K4C//Oj s+g6+WmqFo2+w6h32QUg== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xfjtkgjrq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 13 Apr 2024 15:21:32 +0000 (GMT) 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 43DFLVH4027478 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 13 Apr 2024 15:21:31 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.1544.9; Sat, 13 Apr 2024 08:21:24 -0700 From: Jagadeesh Kona To: Bjorn Andersson , Michael Turquette , Stephen Boyd , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Mauro Carvalho Chehab , Ulf Hansson , "Rafael J . Wysocki" , Kevin Hilman , Pavel Machek , Len Brown , Greg Kroah-Hartman , Konrad Dybcio , "Andy Gross" , Dmitry Baryshkov , Abel Vesa CC: , , , , , Taniya Das , "Satya Priya Kakitapalli" , Imran Shaik , Ajit Pandey , "Jagadeesh Kona" Subject: [PATCH V5 RESEND 3/5] clk: qcom: gdsc: Add set and get hwmode callbacks to switch GDSC mode Date: Sat, 13 Apr 2024 20:50:11 +0530 Message-ID: <20240413152013.22307-4-quic_jkona@quicinc.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240413152013.22307-1-quic_jkona@quicinc.com> References: <20240413152013.22307-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-ORIG-GUID: WWYiOEBvnAea0ooKlaywi4XnKgXut6xi X-Proofpoint-GUID: WWYiOEBvnAea0ooKlaywi4XnKgXut6xi 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-04-13_04,2024-04-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 malwarescore=0 spamscore=0 lowpriorityscore=0 impostorscore=0 priorityscore=1501 clxscore=1015 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404130113 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 df9618ab7eea..c5f6be8181d8 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