Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2192367rda; Tue, 24 Oct 2023 15:44:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHhtT0erXWf7SQISlZc5Vu4wNrjBRaGKSLs7T8T8PgkZgR9ZX+eMZC5BQP08BuDRqn6zAhf X-Received: by 2002:a05:6a20:4323:b0:15e:986:d92b with SMTP id h35-20020a056a20432300b0015e0986d92bmr4329725pzk.16.1698187445248; Tue, 24 Oct 2023 15:44:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698187445; cv=none; d=google.com; s=arc-20160816; b=NLFmp5UAgd7IzCLDlGdQFQHTQ6KmRtnC8tQuvo6n0uaoyTkLFbTX0zsq9flZHzsr+A bt19Cu0bXFmGtIjqN//eU8xoE06XXRXyDh2amwz4fIwob0VYTuutdToUZPR3ZMw+/dVe 2sjAX8RooOkv3+SNDHLnAKjMsBz8eDTqFZDPIPRmme8mnBhuk7dmPHas4l6DQpkXMlSR ycVAWKE7i0qVJ0Ro/nrEBUzOBSgXB5yINX+MzfWrDArMSOmvIo5zkBOeMS7m27++mvbL NYByKmJ+FXcBjCw3IlpAu5+hT5VA1gCjxFPAK2WQK+lAHrYCJp8phpxTPslNQhIdaz1m dqVQ== 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=SrD6kKZF7oe0EGz2m2BzMlSzxhpuIf6zdpgGnAoBqe0=; fh=fyG9SJNmKBoDrwXJiUgMd9DziuhFo2fojtbASvUbY1k=; b=bxhAQiCM+cGoaU7HfKf0j/iygRHQv1HPdDTSnkWpTes1INcL64Tzs+TgV4KTdqjGoK 9xAfQrf4VbWR49eIV6SsHOtsVfkYUSgsOGG04OfrtOHY7cgJOihjkAVwaKCgdzPmugVl UeJmIlWJvcrEbNb9VEypCrRSK3bOr3xLTTFaSR3gqF3DL40ebNzIpcuGv8kXY2D3uew2 dS12LPIlMADk933TsBvJnK+46MeWtPyNtU2LI/cSIbo3vHX+xwG6EjEuasaJ+IaIaEgx Xe/8d/CSg64H0YHOuvf8UAxiRf3NvOgErixE0inyZEHR4CwcM3aZ7UNl31Fxj7jA1cGV wCVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RHEOHoJz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id b3-20020a639303000000b005a9c401068esi8589585pge.667.2023.10.24.15.44.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 15:44:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RHEOHoJz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 6F0F680B6C2A; Tue, 24 Oct 2023 15:44:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344591AbjJXWn1 (ORCPT + 99 others); Tue, 24 Oct 2023 18:43:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344581AbjJXWnU (ORCPT ); Tue, 24 Oct 2023 18:43:20 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5FEE10C6 for ; Tue, 24 Oct 2023 15:43:15 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-40907b82ab9so1295265e9.1 for ; Tue, 24 Oct 2023 15:43:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698187394; x=1698792194; 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=SrD6kKZF7oe0EGz2m2BzMlSzxhpuIf6zdpgGnAoBqe0=; b=RHEOHoJzJFJArR915qg0a07zoxtYPHOcfW64btcAsV3T3nqme2vbZFmmgql02eXOr2 P5MJJnE7NE3gG1cxgJw3/kspr9hGS9WboqNNC04aPuFPVIj3JV+PWLvXUTBt/g9vTSCW S4VLy7GS+mcGBeeM9fzCOn+ViZ2Uc+xB2uVlQBc6StdX9QiefvqyD1toUNUDMQDyIacz RHzjr5XBZRiPUoHWFN9+NDpAqLpYlSVyafPdVU7q4r965vZrUVU4LHnaqB5V0/WJcbkU vrgH39kyTsezYSFIT5aC+xwdzRWZuKMg2wynefvQ6wFdLRb789jxVq0MrEHI95G90DLn WQKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698187394; x=1698792194; 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=SrD6kKZF7oe0EGz2m2BzMlSzxhpuIf6zdpgGnAoBqe0=; b=kKcwYMoZ+6bIZwXKa4BhZY8xqafsx9jJVzNzE2/xUpX55z3SSW3z7+awXzAnvOFTLo stEuEqKIQyb1tjaigc28cwrD0fGwj2unci6M4SZ6sYTaZ+46vt0eapgRqGPhcyAE8VEa nddckjcXW0F2uCZl6bss9rGmPnm/cSc5tVBGJCP+U4qHIlzF0poFCa/m2kf6y00jEP/C R1uqVhBVSyv0g5paqnaPZfYEw65mbploIuOd6McxxoOaKwMyZug9tVvbg3a3eyHElJ2W 91cDeR8t41qzDth69RCDr191xQv5Nbbun0sdJYa2taDuFTKi6tkWxD4pGLw0s7Osuj16 wCSw== X-Gm-Message-State: AOJu0YwUGFP/0yUVFj3V/y4AtIZxRy8DY3W2DF23V/z0SKgE+sfXzmOA n8yaxfw6kszeHOlBektIFlwKwQ== X-Received: by 2002:a05:600c:3414:b0:401:c7ec:b930 with SMTP id y20-20020a05600c341400b00401c7ecb930mr15349644wmp.10.1698187394317; Tue, 24 Oct 2023 15:43:14 -0700 (PDT) Received: from sagittarius-a.nxsw.local ([37.228.218.3]) by smtp.gmail.com with ESMTPSA id j6-20020a05600c190600b0040641a9d49bsm13049531wmq.17.2023.10.24.15.43.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 15:43:13 -0700 (PDT) From: Bryan O'Donoghue To: hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, rfoss@kernel.org, todor.too@gmail.com, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Bryan O'Donoghue Subject: [PATCH 4/4] media: qcom: camss: Add support for named power-domains Date: Tue, 24 Oct 2023 23:42:55 +0100 Message-ID: <20231024224255.754779-5-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231024224255.754779-1-bryan.odonoghue@linaro.org> References: <20231024224255.754779-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Tue, 24 Oct 2023 15:44:02 -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 declration 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. 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 bc14ae4771e31..12c64c505befd 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -1381,7 +1381,29 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe, if (!res->line_num) return -EINVAL; - if (camss->genpd) { + /* 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 (camss->genpd && !vfe->genpd) { + /* + * 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 523b36d86f6cf..fb5276f4d9448 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -1506,12 +1506,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 95486c494afc6..6762ce9631476 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; const void *ops; }; @@ -83,6 +84,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