Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp1122472rdb; Sat, 18 Nov 2023 04:12:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IGlmfBMYekBXYW1DQwQhLZ+MxnGPIMVbPsB+sTNFjkD5+/RFUUHS8DtJe1t7OVRB/7MCkFL X-Received: by 2002:a05:6808:1a02:b0:3ab:83fe:e182 with SMTP id bk2-20020a0568081a0200b003ab83fee182mr2638825oib.1.1700309533988; Sat, 18 Nov 2023 04:12:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700309533; cv=none; d=google.com; s=arc-20160816; b=j0RtpxhG1IAyaI/9UTGnq8u9+rgidOqpE5HkLVLSbX57WGuneEtFZgW1h85kpXY70O AHmNEdvQqzetGWl7cQkdA640Y8g5/VY3qv9AIiqC/DJd2N4zM/5A3DjFmFUw1td5SbHM VAiFgW9lCaf7K3UkzMRiBPQQO8MDGl91+C7Kz/oags0fSwOBHRTYplmUIO5OY8OZa9S5 9+Elk00Q7bogFrveZ4FRGaF60aYLRayRsSb/MVNDW+UXzg2HekjzmqnALThQWeqSAWiI n9sUmg1ItW8kXwcY+vTDQBh465o8Ozx0OPDSDDAkI/Vx36BBBCpwnzFtN+wmeJpNBO+M ovPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=D/8fK5MG4KKExAgvblqrwgiM/n1djTKuGsICPn9EaDo=; fh=+21+21gNft/7To99MfcGJu9QkWyyZ7J1aCqrKBAZjFw=; b=XfDRrwF6nCIAU4YAF3bLELUA0/k7emoEM9mEL3k87IUot2oei0nyVUDkxxWrAvLFIl oH3GAlacLJrbW9mUyH49agAO0YdzCBOOTmpzj/agog2advAmqLPET2kwhg67a9R32i50 UsDC8alfEcuVCJPNJp1ZD3H4c3ventvwAPQMl0IZ7/90RBsA4wMCQom17CzbLJsmiQ2/ 3hgAWSJFNfpXGc+6QeI67xhQs05eXf/gs0b4srLdl97pikTSLXshCOGXSLlxatrZoUge 9WoSE3OXE/S+25070eFiupbTtXuhSnnr8CHG4WFhDMXwiGOUpR2LltWDEah8slSmpDtw 7ESg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IwefrN8O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id cm4-20020a056a020a0400b005c201af09fdsi3720796pgb.575.2023.11.18.04.12.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 04:12:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IwefrN8O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 36EBA80B2303; Sat, 18 Nov 2023 04:12:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230117AbjKRMMF (ORCPT + 99 others); Sat, 18 Nov 2023 07:12:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229872AbjKRMLx (ORCPT ); Sat, 18 Nov 2023 07:11:53 -0500 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41134D7A for ; Sat, 18 Nov 2023 04:11:47 -0800 (PST) Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2c5056059e0so39815591fa.3 for ; Sat, 18 Nov 2023 04:11:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700309505; x=1700914305; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=D/8fK5MG4KKExAgvblqrwgiM/n1djTKuGsICPn9EaDo=; b=IwefrN8OQ8X8cFrRCmZV9R8HCOXTKGedUf1jeSIgB1yrM1HdEFiPednca7avo8DXZg Ng1T5U3dulgMg2R5mvlAmhSRa+t1y2T3vru9TJ7W7UmThCxwU9PG+IzGhe6HGBFP3EZC N4xZBVBWFp38gQkV9XsXPTlc6y2d14nkQCSQUIn+d8FWw6MSZVQkrCBg4slRq+uhQB9Q wML2ZX0fA4C/UFzHJDxKqGvfuiPiXY0n0vba01TVG6V3RKtGLYdLpNSvvDnqToSWUb9L EiQ0UMM+UvdwW6/iicJ9FqPsJeqAwWFkwTaJxhw8XitVCGOsBulnhalrudDB02yDtI5g o11g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700309505; x=1700914305; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D/8fK5MG4KKExAgvblqrwgiM/n1djTKuGsICPn9EaDo=; b=jOjz3lXnIZxElKICre+MoN1+HcvNM0erfBVFtQfKsDKyYlGomNvhk1Gk8/5vtNefwn lqNcT4Y2AWBRxvBnQS9HckrGD2pGHkZNS98W2o5mPMndrcncdRbD9EsJstXfACcbxjj1 SGIr7gyRgz77yE5jnR9Ll972opohlRQUlsjy9VNtPMo65CQDnmMe/fQneBuqDy46+O24 5T5jvQSl7PfvsdUVUaIkSmJQtdhCN3lqWe6T31Ukgx4Q5KTcylnTRS90rlejQeCu2aZ9 UrVo2Q4vwnGuOjT8RWouXqhadrGlrPvx1oi6qJE+zIZ8RTFTSD4+TQqY5bIIacAXamDg if3g== X-Gm-Message-State: AOJu0YyHhpZq+p9M4lNECm33AfItydK6WbTNiRiiFr+fd97tl7SVGdFd 6K78nk5/KmyIVPX7+Nl3h+dhPQ== X-Received: by 2002:a2e:8e32:0:b0:2c8:7665:9ede with SMTP id r18-20020a2e8e32000000b002c876659edemr987336ljk.19.1700309505390; Sat, 18 Nov 2023 04:11:45 -0800 (PST) Received: from [127.0.0.1] ([37.228.218.3]) by smtp.gmail.com with ESMTPSA id n18-20020a05600c3b9200b00407efbc4361sm10955775wms.9.2023.11.18.04.11.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 04:11:44 -0800 (PST) From: Bryan O'Donoghue Date: Sat, 18 Nov 2023 12:11:39 +0000 Subject: [PATCH v5 5/7] media: qcom: camss: Add support for named power-domains MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20231118-b4-camss-named-power-domains-v5-5-55eb0f35a30a@linaro.org> References: <20231118-b4-camss-named-power-domains-v5-0-55eb0f35a30a@linaro.org> In-Reply-To: <20231118-b4-camss-named-power-domains-v5-0-55eb0f35a30a@linaro.org> To: hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, Robert Foss , Todor Tomov , Bryan O'Donoghue , Andy Gross , Bjorn Andersson , Konrad Dybcio , Mauro Carvalho Chehab , matti.lehtimaki@gmail.com, quic_grosikop@quicinc.com Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.13-dev-26615 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_BLOCKED, 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sat, 18 Nov 2023 04:12:12 -0800 (PST) Right now we use fixed indexes to assign power-domains, with a requirement for the TOP GDSC to come last in the list. Adding support for named power-domains means the declaration in the dtsi can come in any order. After this change we continue to support the old indexing - if a SoC resource declaration or the in-use dtb doesn't declare power-domain names we fall back to the default legacy indexing. From this point on though new SoC additions should contain named power-domains, eventually we will drop support for legacy indexing. Tested-by: Matti Lehtimäki Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss-vfe.c | 24 +++++++++++++++++++++++- drivers/media/platform/qcom/camss/camss.c | 26 +++++++++++++++++++++----- drivers/media/platform/qcom/camss/camss.h | 2 ++ 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c index defff24f07ce3..123e5ead7602d 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -1382,7 +1382,29 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe, if (!res->line_num) return -EINVAL; - if (res->has_pd) { + /* Power domain */ + + if (res->pd_name) { + vfe->genpd = dev_pm_domain_attach_by_name(camss->dev, + res->pd_name); + if (IS_ERR(vfe->genpd)) { + ret = PTR_ERR(vfe->genpd); + return ret; + } + } + + if (!vfe->genpd && res->has_pd) { + /* + * Legacy magic index. + * Requires + * power-domain = , + * , + * + * id must correspondng to the index of the VFE which must + * come before the TOP GDSC. VFE Lite has no individually + * collapasible domain which is why id < vfe_num is a valid + * check. + */ vfe->genpd = dev_pm_domain_attach_by_id(camss->dev, id); if (IS_ERR(vfe->genpd)) { ret = PTR_ERR(vfe->genpd); diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c index 5f7a3b17e25d7..ee3e8cefa9b1f 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -1522,12 +1522,28 @@ static int camss_configure_pd(struct camss *camss) return 0; /* - * VFE power domains are in the beginning of the list, and while all - * power domains should be attached, only if TITAN_TOP power domain is - * found in the list, it should be linked over here. + * If a power-domain name is defined try to use it. + * It is possible we are running a new kernel with an old dtb so + * fallback to indexes even if a pd_name is defined but not found. */ - camss->genpd = dev_pm_domain_attach_by_id(camss->dev, camss->genpd_num - 1); - if (IS_ERR(camss->genpd)) { + if (camss->res->pd_name) { + camss->genpd = dev_pm_domain_attach_by_name(camss->dev, + camss->res->pd_name); + if (IS_ERR(camss->genpd)) { + ret = PTR_ERR(camss->genpd); + goto fail_pm; + } + } + + if (!camss->genpd) { + /* + * Legacy magic index. TITAN_TOP GDSC must be the last + * item in the power-domain list. + */ + camss->genpd = dev_pm_domain_attach_by_id(camss->dev, + camss->genpd_num - 1); + } + if (IS_ERR_OR_NULL(camss->genpd)) { ret = PTR_ERR(camss->genpd); goto fail_pm; } diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h index 1ba824a2cb76c..cd8186fe1797b 100644 --- a/drivers/media/platform/qcom/camss/camss.h +++ b/drivers/media/platform/qcom/camss/camss.h @@ -48,6 +48,7 @@ struct camss_subdev_resources { u32 clock_rate[CAMSS_RES_MAX][CAMSS_RES_MAX]; char *reg[CAMSS_RES_MAX]; char *interrupt[CAMSS_RES_MAX]; + char *pd_name; u8 line_num; bool has_pd; const void *ops; @@ -84,6 +85,7 @@ enum icc_count { struct camss_resources { enum camss_version version; + const char *pd_name; const struct camss_subdev_resources *csiphy_res; const struct camss_subdev_resources *csid_res; const struct camss_subdev_resources *ispif_res; -- 2.42.0