Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp935175rdb; Wed, 6 Dec 2023 04:25:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IH5Bxn4ynwpG7pDzRORe/ZJEipNH61NJmh4dTU8nhTB+HLsxeqNbrGBrYJnNmKac1mRtRtl X-Received: by 2002:a05:6a00:1393:b0:6ce:3e7a:cfad with SMTP id t19-20020a056a00139300b006ce3e7acfadmr634236pfg.0.1701865549382; Wed, 06 Dec 2023 04:25:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701865549; cv=none; d=google.com; s=arc-20160816; b=KeMPe0nTYZzfLD+afInYzODjWeSTJsMALXjcTeze6hB6x8PejzC7RUNlit6ZKBMQ2E CrK8ise8BpChPYbzS/+28CSWlANFFP+WE+evAmLkW4isSUty0FlEL9EI30D9aQEg1AFv rssFq6vKQ7w4WA8uOTXFCDpmDi7vgLmOASSNk744Xsqnh+fH3aK+KMxfM/Owj0vDytx1 wmOB7hH4VTlvMUnKJ44GjDy03nh0Z6OcZmpVVO9UkzqwBMl6BB4jnV+fqjUEigRLiqxz 0kKhz7XxDi+s0+iR7Z5h87fdYh5WI+VKCYq/Qs1lAnImMBuxPenc1FfgrCm91fFzelT5 izKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bSPJqgRu7qPi+l+hmtBMdBdRoK+soEQmisUntrPtTec=; fh=EGDf8Ar4lVC2OjF74TprjuvMyKCRKZ5adlXpLo6vz3U=; b=aLELzP2FMEhlRtWHjDbGVC3CvD8YX7lnVAEoHs94U4d0bNy3GncDv3+1fXBoW3pl09 kIyj7hrsMwNoDyqktQ1FBpjRkXdbqvozsWgMW59QW//nOnA+4TshUSgeM07Q0qOypXxi AW0k7p46yycKRr9pz8ReZ1QsCZvsJLf5RytUREbt7wlMsvdeS8OEbcqKBSlxE9zXnmF+ Vnc2VggcLAOA7Rinu3kaMQUtah//kZStoVlpECDbVDOuNcdsY574gQOUbiN1+yfYAJNY rGeV7Pg2qnqi/J3bpr0DgzO5ooy2LQprbswmEFDpbhuk/4iN3YUXwsgI+9T296VHl7Cl HlNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L7E3hyDL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id n186-20020a6327c3000000b005c690ba4078si5286375pgn.410.2023.12.06.04.25.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 04:25:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L7E3hyDL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 27948807E007; Wed, 6 Dec 2023 04:25:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378056AbjLFMZG (ORCPT + 99 others); Wed, 6 Dec 2023 07:25:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377925AbjLFMZE (ORCPT ); Wed, 6 Dec 2023 07:25:04 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFD4211F for ; Wed, 6 Dec 2023 04:25:06 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-9e1021dbd28so95413666b.3 for ; Wed, 06 Dec 2023 04:25:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701865505; x=1702470305; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bSPJqgRu7qPi+l+hmtBMdBdRoK+soEQmisUntrPtTec=; b=L7E3hyDLPETIVo6Mm8tHN2xAZSS7M80MQ/DlspehVsODjU4ROfs9Sg47z0PjkI5fPI vRqf1Irz2RrNMhKQ06qWb3KW96Jr8OtVFGAeCo/+uPcnkeYSnyGFP0C2UrrqjYUTrGN0 q0z3Hv717Ev/hgYB0upmm+X2EfFyVF2LD3khSZaTjKwG3itzCCzMzMRQz8GLsVx5hPo4 W0DQWxlu27iBHzBSQlj/BNB2KAIWvRAZlY0nW0NN6IJ7llIt891+eJl9WExf0RZvNIN6 zY0N8aDdHKMwWGkEEmCBLE2nRK0Tou3iQ3aOSCR1iLQlE9FyZrMGscUJs48dXiwxyoGj Fkvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701865505; x=1702470305; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bSPJqgRu7qPi+l+hmtBMdBdRoK+soEQmisUntrPtTec=; b=cHLzg3/tVHwd7A0/vVV2jAY7HiOSP/ATlZy33rvW3+Bw/DotTumwsQmOSEbSd0N6Fr DuQ9Tq3BCkhc1TLbE/CSmmN6EF9z1wtS3LirrTAOHJCJ/BYW51ceoXTY+Zw2r5TvWnrj gi8wzpEoLQMJavc6edgrwQrXNHGWFGqzU67awYAW8SGTuG8pQ4/4DB88A5hLzPYbspSX NMeZhIIvNn/RbwcOCv6G1NpZ3YdEl8bLIljh5tqP/w9ZhPuPumGahDJZ6sBuZ+/xVBWB oG5GdD0N3tVv4lolp37uoXNkrrQaifUaAUmF9lplBSaoB9697K64UMF/WfLNru4hakmA 853w== X-Gm-Message-State: AOJu0Yy82QEWHB6GTsQysSbIf3Uc0ej6OtPFFzmqLekiEAUqt//ZQJS6 mu4fY7nux2kPLAjjAzo9otmm0Q== X-Received: by 2002:a17:906:fc06:b0:a1c:fdb2:e9a7 with SMTP id ov6-20020a170906fc0600b00a1cfdb2e9a7mr476301ejb.141.1701865505354; Wed, 06 Dec 2023 04:25:05 -0800 (PST) Received: from localhost.localdomain (2001-1c06-2302-5600-366d-ca8f-f3af-0381.cable.dynamic.v6.ziggo.nl. [2001:1c06:2302:5600:366d:ca8f:f3af:381]) by smtp.gmail.com with ESMTPSA id oz23-20020a170906cd1700b00a0ad10b3f68sm8188085ejb.205.2023.12.06.04.25.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 04:25:04 -0800 (PST) From: Bryan O'Donoghue To: laurent.pinchart@ideasonboard.com, rfoss@kernel.org, todor.too@gmail.com, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, mchehab@kernel.org, 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, Bryan O'Donoghue Subject: [PATCH v6.1] media: qcom: camss: Add support for named power-domains Date: Wed, 6 Dec 2023 13:25:00 +0100 Message-ID: <20231206122500.3798228-1-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <43621420-2482-4634-9c3e-1a3278481540@xs4all.nl> References: <43621420-2482-4634-9c3e-1a3278481540@xs4all.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 morse.vger.email 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 (morse.vger.email [0.0.0.0]); Wed, 06 Dec 2023 04:25:21 -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 | 31 +++++++++++++++---- drivers/media/platform/qcom/camss/camss.h | 2 ++ 3 files changed, 50 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c index 60c4730e7c9d..083d1445a6e2 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)) return PTR_ERR(vfe->genpd); diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c index 35918cf837bd..8de0e9e8d34b 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -1522,13 +1522,32 @@ 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)) { - ret = PTR_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)) { + if (!camss->genpd) + ret = -ENODEV; + else + ret = PTR_ERR(camss->genpd); goto fail_pm; } camss->genpd_link = device_link_add(camss->dev, camss->genpd, diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h index 1ba824a2cb76..cd8186fe1797 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