Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp439606rdf; Fri, 3 Nov 2023 05:29:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IENjIFZNLAX4N8JyCJ9pkwUbCJTIUk7RU8ujpAyD06mLMx0ZdITfI/F0Gccds5jMWiwuKvc X-Received: by 2002:a05:6a00:1798:b0:6ad:535e:6ed9 with SMTP id s24-20020a056a00179800b006ad535e6ed9mr23455870pfg.16.1699014591533; Fri, 03 Nov 2023 05:29:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699014591; cv=none; d=google.com; s=arc-20160816; b=z3F9XHBVcBOo7umXU7qlIujbGp0IO6RsQrVnmO62/rmtl0dw6ZYENcUKJkPWRbV3AB KCIn5q/MXJJ4imTxoBbxv1Nt6Y/hWMzRx2g9Lbl0AZhS4Kf7kLihDLJ8oKVQW9t3XgFg OJnE7Pr0Xo2XwJ/U9ZY+/X8v2lJjfG7hQ2wjPeOezM77ivFNx8yaq32AUYu2V6fx6jiT 03a06ZLRi6XZSyGImWXY7bl2z/Pux0INx6cGrXngtoYw+wA5nOQv/lWPkhpyGgNopBW9 lhjHscC3OgFz+m413vF+AqSam8R4bCJfjXDhGBjdrKDEibJupInRrBNZ3BHaKreZjkQY HEnA== 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=md6OhgYeiqhW8v0ZSLxkHkjOlO44qdIptAA7zD8mXLI=; fh=+21+21gNft/7To99MfcGJu9QkWyyZ7J1aCqrKBAZjFw=; b=CSt0GVKQRWT4zSFH0vLG002HqffRIrhgB8SMtFXzb5s5/GOMwEUZpEPY5MVRhOjjWv ohj/7i9DcoMkt717Uu8vQp9mx3MgZLPGTPgyrxawMoPHdlokYDfkYgibcU5m6o6mqqQR a7Iu2EeEIPpSe1vHp9mEpA/entGsRPIYghxNqoTH7gt79CQk81TvFHzXWnKJEALN4as7 XMZdPFRO84n6x0wfEAEuL7/4aHm2p15MhxoirKw31T6bmwA2FE5EUqxkfIPYyx/bBuh4 87zeyjrqeNCW1FITj/+O7zG1BVxp7aFj/J3SrEbpUbvd3GKiVpfcTQsX2y0DEB8Ekh1W iPCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="WFMvMzv/"; 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 m3-20020a056a00080300b006c2cb9a884fsi1455524pfk.293.2023.11.03.05.29.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 05:29:51 -0700 (PDT) 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="WFMvMzv/"; 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 18E9D8312F9D; Fri, 3 Nov 2023 05:29:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377151AbjKCM3h (ORCPT + 99 others); Fri, 3 Nov 2023 08:29:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376466AbjKCM3U (ORCPT ); Fri, 3 Nov 2023 08:29:20 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E252CD4B for ; Fri, 3 Nov 2023 05:29:08 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4083dbc43cfso12881695e9.3 for ; Fri, 03 Nov 2023 05:29:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699014547; x=1699619347; 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=md6OhgYeiqhW8v0ZSLxkHkjOlO44qdIptAA7zD8mXLI=; b=WFMvMzv/rrLiWMFY+y/J+drJSVY7+l7AQkEhF4g4yHCHVcQNbIUymwfq5dsnkKpWs2 8SGMxSEzyN1aSR8Vp7c7db2GXkpwbRn1iRSTlEqC0h+0bKNyULIzuEpCVU2dLyMkoIHW rG7aU4CxKuDv2EtnOIGIPm+TKfvazapZ44byCbrrRM1Fe1rGiqD1a8YMkuSRLaqY1lwq ogEv7LWBoRb7S/Qj+TrxwpYhZJPqmUqadNk8yfYK2i57CJUf+O+Znz3okaJnZFUeNQre rZxwGtH/X7epioKVCa/ExVfqFoi9pyUkRTWYTp3l/nzpli/AigUJa1wdifR04YWvX9b5 96Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699014547; x=1699619347; 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=md6OhgYeiqhW8v0ZSLxkHkjOlO44qdIptAA7zD8mXLI=; b=JiqNrVA93dKCrZ+uwsmec8GpevmifNDshYsk//wRL7wOs4fGcFbz3qP7tHEVTP8M2U kwHI6pv3K5QCjHY+0r2wvaXwABWWhvvJkhxtlt5KYKakeULB5LoS2vUKZVOxl1R8Gh86 0VFahouHSHZp7nCzmzopw/wvMzh4MJGyzspu3LYR6eGwA8lIKnG3IbI9IQ6tHbnTJ6sX hTSm9n1SJ5lIWgmtmJNb4CMbOlEVadOEwioZsjeHZ7TcXNrJQVhuu/FnkA0ePGKtyxq9 e95TFEJgW6m2NhBG/xB0HzJswO8M1Gvd0ze1qzjMGxcA+axhIL+sv9cD/xndmPcg88tw L+Zg== X-Gm-Message-State: AOJu0YwjmtCat4iL/sNKVxLcLMQsHAgx3FA9VxTCdiJUHa1CD34ncbGP 2CmAqAemNzBIWUssnopB/KIwgg== X-Received: by 2002:a05:600c:350c:b0:409:6e0e:e95c with SMTP id h12-20020a05600c350c00b004096e0ee95cmr2099114wmq.21.1699014547402; Fri, 03 Nov 2023 05:29:07 -0700 (PDT) Received: from [127.0.0.1] ([37.228.218.3]) by smtp.gmail.com with ESMTPSA id ay8-20020a05600c1e0800b0040772138bb7sm2402918wmb.2.2023.11.03.05.29.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 05:29:06 -0700 (PDT) From: Bryan O'Donoghue Date: Fri, 03 Nov 2023 12:29:02 +0000 Subject: [PATCH v4 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: <20231103-b4-camss-named-power-domains-v4-5-33a905359dbc@linaro.org> References: <20231103-b4-camss-named-power-domains-v4-0-33a905359dbc@linaro.org> In-Reply-To: <20231103-b4-camss-named-power-domains-v4-0-33a905359dbc@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]); Fri, 03 Nov 2023 05:29:50 -0700 (PDT) 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 f10a47f1aee7d..d565260fee0d6 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -1523,12 +1523,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