From patchwork Fri Nov 3 12:28:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 161257 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp990760vqu; Fri, 3 Nov 2023 05:29:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF1v/RPugL51tfs27byn+D4CC42W5NpTJb+EiXQbCEnd4ASzGxwzUdUYKmMKwkX0Uk+UI2P X-Received: by 2002:a17:902:ce87:b0:1cc:636f:f376 with SMTP id f7-20020a170902ce8700b001cc636ff376mr13299883plg.44.1699014563811; Fri, 03 Nov 2023 05:29:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699014563; cv=none; d=google.com; s=arc-20160816; b=u6puMKraY2P+cpnl3hG0DR7nsF/8cIFdKzcB8Rh9sH9rsdOZ52cdL+3hstNlRVul0u LWTmdGHrErUVoaM4Ffvqhwya+fd/msRINu4xQjwUADETkTrMwRqNCpENUIfNG70XywwN cgdTzkXYVsGPmTe6NnxonmWJvRe/jxCGaN7c/+1zj6M51T6kIHP1S1nz5nmV/LE2xIo2 Xj3KhaG8Imol1KOy6r5on9ja9usM7MKrz49WPPN5ljg91vrh8rybXb3R4ap4AbdMQn31 LbBhKH6nHa+LsJccTo7MbLNrUeTeA3Q1n7dMO5RO4nsa7zfWhFnLMbQW9sV1K/L634Ox rJxQ== 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=X26+8wItEuS2j+BVlRHOHS9xadXwL+/+KykUmMySayM=; fh=+21+21gNft/7To99MfcGJu9QkWyyZ7J1aCqrKBAZjFw=; b=zTYEqLLNmR1N4okYeqWn6wyTkma1n9rDOnlFsmpgOkyWJ8WFZjE8qolYlsOBZCF0uc BdDO1I14m062wWMxR3I9WrrJjt8ZLKL/wjfidp8GlW+1RLn34IIQyNuaMxRolS5cMtHW fkGelSAYNoqtUvHz2IOq1HuJl/okmmJQ5wVdL/q+9jbSrPgm/C3zRjgmBijeKBeYPLtS 65WweHrJIdfIY36NXhPJkHwnTZhpHWARhuucFNJXy2rvc6/I+C6jsYZncBJ9egq2q0/H toEXqqnFBPnOj8cUaGcnWCLtXAAUWfXOkATrmF9JPBPTCFyxAzlUkcr9Ea2CroXiOMUc NjUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wmqclJiT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id o5-20020a170902e28500b001bb6d711625si1373137plc.279.2023.11.03.05.29.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 05:29:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wmqclJiT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 2709281373DE; Fri, 3 Nov 2023 05:29:20 -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 S1376461AbjKCM3M (ORCPT + 36 others); Fri, 3 Nov 2023 08:29:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376451AbjKCM3K (ORCPT ); Fri, 3 Nov 2023 08:29:10 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F3071A8 for ; Fri, 3 Nov 2023 05:29:04 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4084095722aso14909135e9.1 for ; Fri, 03 Nov 2023 05:29:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699014542; x=1699619342; 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=X26+8wItEuS2j+BVlRHOHS9xadXwL+/+KykUmMySayM=; b=wmqclJiT8CLQsS9V4QC1RDHpyFRE7DxyW8ZLCFGauC19Tx1IZVF1btplKs05NM2jkW CjsnNuXkTB+6MPrKaXxjbODfjV2ylm9sIJZFlGuiqR9xr2wGaxc+sNkbdSGhCKLtPuXg aVTk02X5DnW8QP+2FGf7gBheicXTmprreKibot7hbEv3dAhg0cPPZXQ6lrma9NhxLxer MTiT1H2EffbouwRXztSQ7Nqw1LtY3s6TgZYRXR6Tu4VfoKtrboVjAaCh+h8wUUycURhh 2h8nSuo1KSXVcxacDOaxJ0hfCbEqUKStrm4ZXJYUcapJfPNh+x7EnZx+B5NW/k/huTQC EBEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699014542; x=1699619342; 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=X26+8wItEuS2j+BVlRHOHS9xadXwL+/+KykUmMySayM=; b=Wibv9MUr35BlSmjn4enwiJTvtsURuCv1UqRr/Hl17Y95fpha31IrD/jXodDYglYSwN SeJjsl85HXJNBYCbnmxRNFRojEOkBOqUaXprYgfYn2YMBE+S40I3wtA6aZZht1BGwFnt c+TCZb6gmTC7twFm+lcurXi0OUVds/picDzoip2+TLzZF3sD5yJuFvSLZMaJ/YqxIzJU yeVJw3+90YrL45ybT8nv5HcYbAHs7KROi7Ic3fCLYjQD6hRRVkud9TQ4cC3tEMwSJJIF h31d7lnKxmwRH8x/1XZScEUNHj74NpLvVYSumto7HJdvAtEY/2BNKdOO8ihDvDIFbUtX qk3g== X-Gm-Message-State: AOJu0YwhyBTOo6ep+HQCZs8tp5UKqtntWmHd2g1LhiU/KWHYfsod9r0m P/Im5k9tvasuCoIEBsvomgS0zA== X-Received: by 2002:a05:600c:d8:b0:409:718b:33e0 with SMTP id u24-20020a05600c00d800b00409718b33e0mr1183300wmm.16.1699014542297; Fri, 03 Nov 2023 05:29:02 -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.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 05:29:01 -0700 (PDT) From: Bryan O'Donoghue Date: Fri, 03 Nov 2023 12:28:58 +0000 Subject: [PATCH v4 1/7] media: qcom: camss: Flag which VFEs require a power-domain MIME-Version: 1.0 Message-Id: <20231103-b4-camss-named-power-domains-v4-1-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=ham 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:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781545895215462856 X-GMAIL-MSGID: 1781545895215462856 At the moment we have some complex code for determining if a VFE requires a power-domain attachment. Particularly discordant in this scheme is the subtle reliance on VFE and VFE Lite declaration ordering in our resources. VFE id is used to determine if a VFE is lite or not and consequently if a VFE requires power-domain attachment. VFE Lite though is not a correct delineation between power-domain and non power-domain state since early SoCs have neither VFE Lite nor power-domains attached to VFEs. Introduce has_pd to the VFE resource structure to allow the CAMSS code to understand if it needs to try to attach a power-domain for a given VFE. As a side-effect from this we no longer need to care about VFE Lite or non-Lite or the id number associated with either and which order the VFE/VFE Lite was declared in. Reviewed-by: Konrad Dybcio Tested-by: Matti Lehtimäki Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss.c | 8 ++++++++ drivers/media/platform/qcom/camss/camss.h | 1 + 2 files changed, 9 insertions(+) diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c index 8e78dd8d5961e..ed01a3ac7a38e 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -278,6 +278,7 @@ static const struct camss_subdev_resources vfe_res_8x96[] = { .reg = { "vfe0" }, .interrupt = { "vfe0" }, .line_num = 3, + .has_pd = true, .ops = &vfe_ops_4_7 }, @@ -298,6 +299,7 @@ static const struct camss_subdev_resources vfe_res_8x96[] = { .reg = { "vfe1" }, .interrupt = { "vfe1" }, .line_num = 3, + .has_pd = true, .ops = &vfe_ops_4_7 } }; @@ -468,6 +470,7 @@ static const struct camss_subdev_resources vfe_res_660[] = { .reg = { "vfe0" }, .interrupt = { "vfe0" }, .line_num = 3, + .has_pd = true, .ops = &vfe_ops_4_8 }, @@ -491,6 +494,7 @@ static const struct camss_subdev_resources vfe_res_660[] = { .reg = { "vfe1" }, .interrupt = { "vfe1" }, .line_num = 3, + .has_pd = true, .ops = &vfe_ops_4_8 } }; @@ -658,6 +662,7 @@ static const struct camss_subdev_resources vfe_res_845[] = { .reg = { "vfe0" }, .interrupt = { "vfe0" }, .line_num = 4, + .has_pd = true, .ops = &vfe_ops_170 }, @@ -680,6 +685,7 @@ static const struct camss_subdev_resources vfe_res_845[] = { .reg = { "vfe1" }, .interrupt = { "vfe1" }, .line_num = 4, + .has_pd = true, .ops = &vfe_ops_170 }, @@ -840,6 +846,7 @@ static const struct camss_subdev_resources vfe_res_8250[] = { .reg = { "vfe0" }, .interrupt = { "vfe0" }, .line_num = 3, + .has_pd = true, .ops = &vfe_ops_480 }, /* VFE1 */ @@ -860,6 +867,7 @@ static const struct camss_subdev_resources vfe_res_8250[] = { .reg = { "vfe1" }, .interrupt = { "vfe1" }, .line_num = 3, + .has_pd = true, .ops = &vfe_ops_480 }, /* VFE2 (lite) */ diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h index 8acad7321c09d..b854cff1774d4 100644 --- a/drivers/media/platform/qcom/camss/camss.h +++ b/drivers/media/platform/qcom/camss/camss.h @@ -49,6 +49,7 @@ struct camss_subdev_resources { char *reg[CAMSS_RES_MAX]; char *interrupt[CAMSS_RES_MAX]; u8 line_num; + bool has_pd; const void *ops; }; From patchwork Fri Nov 3 12:28:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 161262 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp992032vqu; Fri, 3 Nov 2023 05:31:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGk4Amntu6je2CpdlEiNm5Iloj/yC87UNdqTNd0ud8cYYksvzHk6umN/mmawHtMF4sc6ULw X-Received: by 2002:a17:902:f394:b0:1c9:b2c1:139c with SMTP id f20-20020a170902f39400b001c9b2c1139cmr17425120ple.62.1699014671164; Fri, 03 Nov 2023 05:31:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699014671; cv=none; d=google.com; s=arc-20160816; b=DjwDflQ4h5j7eTaT80Ltkvz9vHGqOF5PaVqan6ykFUzEKN0RCyOOF0b11z7EEv1gtF LEcy/Zd4hB2KYQHRHPLdJ+z6623t6vYhk7i+cnxDK9zgFvfwIR4tN0SvV4s3kq9bwBYU Rr5nQlSI1ElM4fuWdpWj+WYL+WYgYVoGDRLVIgTYO62KUHsjZsxvWA/Y9+NMVZ3m5CeO 7qLx+gkNM2Rd35cUXNdodJ+NDghrOCMzM03hfjibQLGab0wyXEjJERV19efZ5n1O3JsB sxjf7DRpJkWqynRoCsNW91MOFtzCQl0IpRHzJdaLsAMK+Qnrztf2kp0B5vAAgZOKNeno Qakw== 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=FU64yB094w/k/dpqAQjQeJG192Ggsw7tuSAo8zmyjiE=; fh=+21+21gNft/7To99MfcGJu9QkWyyZ7J1aCqrKBAZjFw=; b=c354Ekyiuo9LSA6yRC2oiZFEngDsh6GLfTuuSdprOIAd4uBmoWRdDx+o3UiV8agWl9 fFVQsxq3aIYwYTHtldeCBwAnsiJTmI8POa0hW4vIjlLqt6KbDHeD2aHJkBKQhTO75CPq kigCptvct5Y1zXIXIlQwsGtrwcYMi4sqmglQSeTioXEUlh/6FDH5prCamwRUjC2crmlh HuqKM25cLj5Ggx4B5M5lWBqOtk4LnCLDta5hL3Eq41ZxdDgYVOkyIKgJGPPU0BMYXJ+3 3D0qOxCVic4KRdHddRTKqhNTDVP3eisvokOGt8X+b11dSa/Fzkku/IvfULveoFDqWubU c26g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EKoJ7LaZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id o11-20020a1709026b0b00b001c3845d008csi1458047plk.424.2023.11.03.05.31.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 05:31:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EKoJ7LaZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id BC65481E5E4B; Fri, 3 Nov 2023 05:30:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376530AbjKCM3P (ORCPT + 36 others); Fri, 3 Nov 2023 08:29:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376487AbjKCM3M (ORCPT ); Fri, 3 Nov 2023 08:29:12 -0400 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54305D4E for ; Fri, 3 Nov 2023 05:29:05 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2c50ec238aeso28527871fa.0 for ; Fri, 03 Nov 2023 05:29:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699014543; x=1699619343; 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=FU64yB094w/k/dpqAQjQeJG192Ggsw7tuSAo8zmyjiE=; b=EKoJ7LaZACe9GKtFb2In9X5Sb9O8CVoLn3WROj96jW27SvZutXm2rj4kiSDY+w5LUc rdsTPOUveFGEYE/SU4KdjzQr6ESxKqx4HWS2K/P5FEaYANp+/3sh9YGd01HhEyT/nXEK rypB6kbhnSaFj+pprhXVRfawhE1MWeN0nYsb7AnMeja7XkA2tLLlbR3v6kbk1AN/vwYT PRfi8Kxh37kOJfi/HohyO4YwtanqRrYfJvG88kxADQL0Ta1tKwKAbr9jCkfHlo+EGUrH jJko66EqgCOS4HuHXC9tDdeJnBv1CD0xzedLRGNbFP1hSay4Cv/EReAdH31lOWq5Jvtb VtMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699014543; x=1699619343; 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=FU64yB094w/k/dpqAQjQeJG192Ggsw7tuSAo8zmyjiE=; b=JXcVCxd+8PB5zJysG7hbDBGrImb+OkzD5ZR7yQCCLlVQq3NaGmjsOktQ9JcETPKWbH VALpZlhLGVjfF9n/NFyLnpmGL9cOoLKCZPG8pMoqK2kVoOCE6BYJtgvcsnQQvDqs7HaZ QWpxjbLrrsKmDOBaUqMyjhyLqrmDVYUa91TqrjD9l15JZZPkb1BeLpziOIBxJSiiOeM9 9FviZOBXTAqV8KLtJvrJ0IVO/mPz0haONJWGAV/ZalQwIiWl2ln977VLyIfVpIl5y1QP zS/VJE1Tk3TbHIhBXC7HTQfoZt8WXmONWYwxXYY8UWVLbeGvI/sC3vy/9jB0MoPN3uQJ UobQ== X-Gm-Message-State: AOJu0YxgSxFdQIgQosDn3B2jMpfLPwod0v2Mpo7U0l3oYsK1VDmyy1s5 i5SdpZnomUm94gT9a/KUGRsp/g== X-Received: by 2002:a2e:9812:0:b0:2c5:844:9e75 with SMTP id a18-20020a2e9812000000b002c508449e75mr17638176ljj.8.1699014543549; Fri, 03 Nov 2023 05:29:03 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 05:29:02 -0700 (PDT) From: Bryan O'Donoghue Date: Fri, 03 Nov 2023 12:28:59 +0000 Subject: [PATCH v4 2/7] media: qcom: camss: Convert to per-VFE pointer for power-domain linkages MIME-Version: 1.0 Message-Id: <20231103-b4-camss-named-power-domains-v4-2-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=-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 agentk.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 (agentk.vger.email [0.0.0.0]); Fri, 03 Nov 2023 05:30:03 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781546007974903824 X-GMAIL-MSGID: 1781546007974903824 Right now we use the top-level camss structure to provide pointers via VFE id index back to genpd linkages. In effect this hard-codes VFE indexes to power-domain indexes in the dtsi and mandates a very particular ordering of power domains in the dtsi, which bears no relationship to a real hardware dependency. As a first step to rationalising the VFE power-domain code and breaking the magic indexing in dtsi use per-VFE pointers to genpd linkages. The top-level index in msm_vfe_subdev_init is still used to attain the initial so no functional or logical change arises from this change. Reviewed-by: Konrad Dybcio Tested-by: Matti Lehtimäki Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss-vfe-170.c | 15 +++++++-------- drivers/media/platform/qcom/camss/camss-vfe-4-7.c | 15 +++++---------- drivers/media/platform/qcom/camss/camss-vfe-4-8.c | 13 +++++-------- drivers/media/platform/qcom/camss/camss-vfe-480.c | 15 +++++++-------- drivers/media/platform/qcom/camss/camss-vfe.c | 3 +++ drivers/media/platform/qcom/camss/camss-vfe.h | 2 ++ 6 files changed, 29 insertions(+), 34 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe-170.c b/drivers/media/platform/qcom/camss/camss-vfe-170.c index 0b211fed12760..7451484317cc3 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-170.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-170.c @@ -638,7 +638,7 @@ static void vfe_pm_domain_off(struct vfe_device *vfe) if (vfe->id >= camss->res->vfe_num) return; - device_link_del(camss->genpd_link[vfe->id]); + device_link_del(vfe->genpd_link); } /* @@ -648,16 +648,15 @@ static void vfe_pm_domain_off(struct vfe_device *vfe) static int vfe_pm_domain_on(struct vfe_device *vfe) { struct camss *camss = vfe->camss; - enum vfe_line_id id = vfe->id; - if (id >= camss->res->vfe_num) + if (vfe->id >= camss->res->vfe_num) return 0; - camss->genpd_link[id] = device_link_add(camss->dev, camss->genpd[id], - DL_FLAG_STATELESS | - DL_FLAG_PM_RUNTIME | - DL_FLAG_RPM_ACTIVE); - if (!camss->genpd_link[id]) + vfe->genpd_link = device_link_add(camss->dev, vfe->genpd, + DL_FLAG_STATELESS | + DL_FLAG_PM_RUNTIME | + DL_FLAG_RPM_ACTIVE); + if (!vfe->genpd_link) return -EINVAL; return 0; diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-7.c b/drivers/media/platform/qcom/camss/camss-vfe-4-7.c index b65ed0fef595e..2b4e7e039407b 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-4-7.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-4-7.c @@ -1109,14 +1109,10 @@ static void vfe_isr_read(struct vfe_device *vfe, u32 *value0, u32 *value1) */ static void vfe_pm_domain_off(struct vfe_device *vfe) { - struct camss *camss; - if (!vfe) return; - camss = vfe->camss; - - device_link_del(camss->genpd_link[vfe->id]); + device_link_del(vfe->genpd_link); } /* @@ -1126,13 +1122,12 @@ static void vfe_pm_domain_off(struct vfe_device *vfe) static int vfe_pm_domain_on(struct vfe_device *vfe) { struct camss *camss = vfe->camss; - enum vfe_line_id id = vfe->id; - camss->genpd_link[id] = device_link_add(camss->dev, camss->genpd[id], DL_FLAG_STATELESS | - DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); + vfe->genpd_link = device_link_add(camss->dev, vfe->genpd, DL_FLAG_STATELESS | + DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); - if (!camss->genpd_link[id]) { - dev_err(vfe->camss->dev, "Failed to add VFE#%d to power domain\n", id); + if (!vfe->genpd_link) { + dev_err(vfe->camss->dev, "Failed to add VFE#%d to power domain\n", vfe->id); return -EINVAL; } diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-8.c b/drivers/media/platform/qcom/camss/camss-vfe-4-8.c index 7b3805177f037..5e95343241304 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-4-8.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-4-8.c @@ -1099,9 +1099,7 @@ static void vfe_isr_read(struct vfe_device *vfe, u32 *value0, u32 *value1) */ static void vfe_pm_domain_off(struct vfe_device *vfe) { - struct camss *camss = vfe->camss; - - device_link_del(camss->genpd_link[vfe->id]); + device_link_del(vfe->genpd_link); } /* @@ -1111,13 +1109,12 @@ static void vfe_pm_domain_off(struct vfe_device *vfe) static int vfe_pm_domain_on(struct vfe_device *vfe) { struct camss *camss = vfe->camss; - enum vfe_line_id id = vfe->id; - camss->genpd_link[id] = device_link_add(camss->dev, camss->genpd[id], DL_FLAG_STATELESS | - DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); + vfe->genpd_link = device_link_add(camss->dev, vfe->genpd, DL_FLAG_STATELESS | + DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); - if (!camss->genpd_link[id]) { - dev_err(vfe->camss->dev, "Failed to add VFE#%d to power domain\n", id); + if (!vfe->genpd_link) { + dev_err(vfe->camss->dev, "Failed to add VFE#%d to power domain\n", vfe->id); return -EINVAL; } diff --git a/drivers/media/platform/qcom/camss/camss-vfe-480.c b/drivers/media/platform/qcom/camss/camss-vfe-480.c index f2368b77fc6d6..a70b8633bb3eb 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-480.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-480.c @@ -463,7 +463,7 @@ static void vfe_pm_domain_off(struct vfe_device *vfe) if (vfe->id >= camss->res->vfe_num) return; - device_link_del(camss->genpd_link[vfe->id]); + device_link_del(vfe->genpd_link); } /* @@ -473,16 +473,15 @@ static void vfe_pm_domain_off(struct vfe_device *vfe) static int vfe_pm_domain_on(struct vfe_device *vfe) { struct camss *camss = vfe->camss; - enum vfe_line_id id = vfe->id; - if (id >= camss->res->vfe_num) + if (vfe->id >= camss->res->vfe_num) return 0; - camss->genpd_link[id] = device_link_add(camss->dev, camss->genpd[id], - DL_FLAG_STATELESS | - DL_FLAG_PM_RUNTIME | - DL_FLAG_RPM_ACTIVE); - if (!camss->genpd_link[id]) + vfe->genpd_link = device_link_add(camss->dev, vfe->genpd, + DL_FLAG_STATELESS | + DL_FLAG_PM_RUNTIME | + DL_FLAG_RPM_ACTIVE); + if (!vfe->genpd_link) return -EINVAL; return 0; diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c index 4839e2cedfe58..94267b9974554 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -1347,6 +1347,9 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe, if (!res->line_num) return -EINVAL; + if (res->has_pd) + vfe->genpd = camss->genpd[id]; + vfe->line_num = res->line_num; vfe->ops->subdev_init(dev, vfe); diff --git a/drivers/media/platform/qcom/camss/camss-vfe.h b/drivers/media/platform/qcom/camss/camss-vfe.h index 09baded0dcdd6..c1c50023d4876 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.h +++ b/drivers/media/platform/qcom/camss/camss-vfe.h @@ -150,6 +150,8 @@ struct vfe_device { const struct vfe_hw_ops_gen1 *ops_gen1; struct vfe_isr_ops isr_ops; struct camss_video_ops video_ops; + struct device *genpd; + struct device_link *genpd_link; }; struct camss_subdev_resources; From patchwork Fri Nov 3 12:29:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 161263 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp992034vqu; Fri, 3 Nov 2023 05:31:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEXgRF2klGyotvkcoguwPniiDu3Rb17M4gT+qGxjrICs2A8eHgItyRHitq9NJIC3W4N+b+N X-Received: by 2002:a05:6a00:1145:b0:693:4a43:1c7e with SMTP id b5-20020a056a00114500b006934a431c7emr19663158pfm.29.1699014671223; Fri, 03 Nov 2023 05:31:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699014671; cv=none; d=google.com; s=arc-20160816; b=Kusr1/tP/EChFN5Re7jKv8ok5Bzm4Lmd7OUi2t5ZiZ/7varvKAuOMxuGxZD18TVLXB 5zBN74aYzdci/uvBg+FmY83b+wz5frjkUNZmv8RVkpPAb8B6tXZ+PRp7uoKi9+TQjaXV m/8ZICXzUvk22g6RkgxYRPn+3P2l5bh9NitZq6iwq2k77FrfziBqcDLs6wDSzBYbmh3T /DxouZbHrRk0QKIfutJMUyNZ02h9j+lVlVwbHeOCwormr2kQwxUGB1XtUwuxFAnGjbxx qe7eV9895TOGweoBS6xMUKAC9la93TSiqEJIpbTQTPimAgqBcSqPigXTW9YeXhpExnbY 0s/Q== 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=1OpluDSI7ifwDeNDFUHoJfsbGgfPas9u/8aOkEgqU+o=; fh=+21+21gNft/7To99MfcGJu9QkWyyZ7J1aCqrKBAZjFw=; b=dMBMX6Pf9Mtza48QNjbiS029k7oKoDmD3tu9MpBL66BKZFopuM/pp3Cx8NRmXtEJRi SV5dHf4Oo4zi9yMYe/uQoX8NJmge/yTvK4TJwdTe0IfUM14363Qp4vzCTG3pB9jP9wQr KhOIFks5T6r5ZbDs9PI9xgukW0IASMy52QOn7S/KjEETqJpkGxaNtJ8Cqnmufu0XEGSV tG6Du0bTIdujWjiDoAIIqFXxmnxpEKQ4M7c3eZuoD18KtmV5i9D/9NrLY18Xluk73QsE SKDw2AvT6sP24kBHjtqwbxjDKCNh5Cju+/K4wCl0ly/P6Q8j/c/7c0k1W/Wvlhxuho8L +KEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ke/3cLeS"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id q186-20020a632ac3000000b005849fe1d3aesi1384051pgq.458.2023.11.03.05.31.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 05:31:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ke/3cLeS"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id E02488076167; Fri, 3 Nov 2023 05:30:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376554AbjKCM3X (ORCPT + 36 others); Fri, 3 Nov 2023 08:29:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376506AbjKCM3N (ORCPT ); Fri, 3 Nov 2023 08:29:13 -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 93948D58 for ; Fri, 3 Nov 2023 05:29:06 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4083cd3917eso15509435e9.3 for ; Fri, 03 Nov 2023 05:29:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699014545; x=1699619345; 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=1OpluDSI7ifwDeNDFUHoJfsbGgfPas9u/8aOkEgqU+o=; b=ke/3cLeSwHfsPCazAdW8pBNXfIz4LB431CMDWi5mlJL3EVNu/3nKX09Ay+SFBGeQgY /NlkHPHKUzNDRSdUQREwe/1za3N2/u8w6WOFQ7BpKRrvkdBgxR+6ZZjXlqbnNg4To6cS Lw2bq9bA93/Kwrvq8xg61pBHiyoY2mra+VhhyunyQJbP0UXQWMimfys62cqaRh5Zq79f hLGjS4WX/Y7IRR/R9t9BiTYLhjUVwvvomST1tyagd0tAFIoOwec03u3Xqr0pP+zPT3s0 xAkcMQ+rRL1J0Bom0Ees3okf0f4CayVGLw5wcS6Y9mDG3xQ/AesmXDNT3maTgod7vDhd MJmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699014545; x=1699619345; 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=1OpluDSI7ifwDeNDFUHoJfsbGgfPas9u/8aOkEgqU+o=; b=DoUybfOuetNwmEAySt5c/z2mUVP1Pk3YbJlY7fPRN9tgezHCZ0ZF48Fggkz4XUj0Yi Rfo3Kp9U3k46jy0MjJs05AyS6s+HJo4xGBNCQuDC0Gj2YHfigDpsTwPiU9I1FBfabhHs AMmCUfHyQSqyztB/F8yna0xr9GlpzFK8rJG0VNYaBwJYPxAxnyIMBRz4RcHeLzLlr1Bj aeSxJiD/r20TT41W9E0oF2vAJmKA/yp0Xc9L537JyJgFBlmwnwzkMOy3ohCgx11LP314 E+II0s5/i/9dGj61oP9HZDiC6uRkoRn33cPfQrTBqwgxSmBZcSpT6AoJEu5yRdfYmFaN vwww== X-Gm-Message-State: AOJu0YxCxFLupiWI7a98VuU+EbNzlskZzbhyeWw21Y/XcjXC1FK0Has3 Qbe2fTCfYyiAojQ4dFNY9YKbJA== X-Received: by 2002:a05:600c:154b:b0:406:4573:81d2 with SMTP id f11-20020a05600c154b00b00406457381d2mr17117468wmg.39.1699014544887; Fri, 03 Nov 2023 05:29:04 -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.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 05:29:04 -0700 (PDT) From: Bryan O'Donoghue Date: Fri, 03 Nov 2023 12:29:00 +0000 Subject: [PATCH v4 3/7] media: qcom: camss: Use common VFE pm_domain_on/pm_domain_off where applicable MIME-Version: 1.0 Message-Id: <20231103-b4-camss-named-power-domains-v4-3-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=-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 agentk.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 (agentk.vger.email [0.0.0.0]); Fri, 03 Nov 2023 05:30:11 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781546007601345677 X-GMAIL-MSGID: 1781546007601345677 For the various versions of VFE we have a boiler-plate pm_domain_on/pm_domain_off callback pair of the general form. - Error check. Not always done but applicable to all. - device_link_add (DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); - Error check returning -EINVAL on error. - Return 0 Reduce the pattern down to a common callback. VFE 4.1 is a special case which to me also indicates that it is worthwhile maintaining an indirection for the vfe_pm_domain_{on|off} for now. Otherwise lets chuck out a bunch of needlessly replicated code. Reviewed-by: Konrad Dybcio Suggested-by: Matti Lehtimäki Tested-by: Matti Lehtimäki Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss-vfe-170.c | 35 ----------------------- drivers/media/platform/qcom/camss/camss-vfe-4-1.c | 8 +++--- drivers/media/platform/qcom/camss/camss-vfe-4-7.c | 31 -------------------- drivers/media/platform/qcom/camss/camss-vfe-4-8.c | 28 ------------------ drivers/media/platform/qcom/camss/camss-vfe-480.c | 35 ----------------------- drivers/media/platform/qcom/camss/camss-vfe.c | 34 ++++++++++++++++++++++ drivers/media/platform/qcom/camss/camss-vfe.h | 12 ++++++++ 7 files changed, 50 insertions(+), 133 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe-170.c b/drivers/media/platform/qcom/camss/camss-vfe-170.c index 7451484317cc3..795ac3815339a 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-170.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-170.c @@ -627,41 +627,6 @@ static void vfe_isr_wm_done(struct vfe_device *vfe, u8 wm) spin_unlock_irqrestore(&vfe->output_lock, flags); } -/* - * vfe_pm_domain_off - Disable power domains specific to this VFE. - * @vfe: VFE Device - */ -static void vfe_pm_domain_off(struct vfe_device *vfe) -{ - struct camss *camss = vfe->camss; - - if (vfe->id >= camss->res->vfe_num) - return; - - device_link_del(vfe->genpd_link); -} - -/* - * vfe_pm_domain_on - Enable power domains specific to this VFE. - * @vfe: VFE Device - */ -static int vfe_pm_domain_on(struct vfe_device *vfe) -{ - struct camss *camss = vfe->camss; - - if (vfe->id >= camss->res->vfe_num) - return 0; - - vfe->genpd_link = device_link_add(camss->dev, vfe->genpd, - DL_FLAG_STATELESS | - DL_FLAG_PM_RUNTIME | - DL_FLAG_RPM_ACTIVE); - if (!vfe->genpd_link) - return -EINVAL; - - return 0; -} - /* * vfe_queue_buffer - Add empty buffer * @vid: Video device structure diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-1.c b/drivers/media/platform/qcom/camss/camss-vfe-4-1.c index 2911e4126e7ad..ef6b34c915df1 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-4-1.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-4-1.c @@ -936,7 +936,7 @@ static irqreturn_t vfe_isr(int irq, void *dev) * vfe_pm_domain_off - Disable power domains specific to this VFE. * @vfe: VFE Device */ -static void vfe_pm_domain_off(struct vfe_device *vfe) +static void vfe_4_1_pm_domain_off(struct vfe_device *vfe) { /* nop */ } @@ -945,7 +945,7 @@ static void vfe_pm_domain_off(struct vfe_device *vfe) * vfe_pm_domain_on - Enable power domains specific to this VFE. * @vfe: VFE Device */ -static int vfe_pm_domain_on(struct vfe_device *vfe) +static int vfe_4_1_pm_domain_on(struct vfe_device *vfe) { return 0; } @@ -999,8 +999,8 @@ const struct vfe_hw_ops vfe_ops_4_1 = { .hw_version = vfe_hw_version, .isr_read = vfe_isr_read, .isr = vfe_isr, - .pm_domain_off = vfe_pm_domain_off, - .pm_domain_on = vfe_pm_domain_on, + .pm_domain_off = vfe_4_1_pm_domain_off, + .pm_domain_on = vfe_4_1_pm_domain_on, .reg_update_clear = vfe_reg_update_clear, .reg_update = vfe_reg_update, .subdev_init = vfe_subdev_init, diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-7.c b/drivers/media/platform/qcom/camss/camss-vfe-4-7.c index 2b4e7e039407b..7655d22a9fda2 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-4-7.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-4-7.c @@ -1103,37 +1103,6 @@ static void vfe_isr_read(struct vfe_device *vfe, u32 *value0, u32 *value1) writel_relaxed(VFE_0_IRQ_CMD_GLOBAL_CLEAR, vfe->base + VFE_0_IRQ_CMD); } -/* - * vfe_pm_domain_off - Disable power domains specific to this VFE. - * @vfe: VFE Device - */ -static void vfe_pm_domain_off(struct vfe_device *vfe) -{ - if (!vfe) - return; - - device_link_del(vfe->genpd_link); -} - -/* - * vfe_pm_domain_on - Enable power domains specific to this VFE. - * @vfe: VFE Device - */ -static int vfe_pm_domain_on(struct vfe_device *vfe) -{ - struct camss *camss = vfe->camss; - - vfe->genpd_link = device_link_add(camss->dev, vfe->genpd, DL_FLAG_STATELESS | - DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); - - if (!vfe->genpd_link) { - dev_err(vfe->camss->dev, "Failed to add VFE#%d to power domain\n", vfe->id); - return -EINVAL; - } - - return 0; -} - static void vfe_violation_read(struct vfe_device *vfe) { u32 violation = readl_relaxed(vfe->base + VFE_0_VIOLATION_STATUS); diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-8.c b/drivers/media/platform/qcom/camss/camss-vfe-4-8.c index 5e95343241304..f52fa30f3853e 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-4-8.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-4-8.c @@ -1093,34 +1093,6 @@ static void vfe_isr_read(struct vfe_device *vfe, u32 *value0, u32 *value1) writel_relaxed(VFE_0_IRQ_CMD_GLOBAL_CLEAR, vfe->base + VFE_0_IRQ_CMD); } -/* - * vfe_pm_domain_off - Disable power domains specific to this VFE. - * @vfe: VFE Device - */ -static void vfe_pm_domain_off(struct vfe_device *vfe) -{ - device_link_del(vfe->genpd_link); -} - -/* - * vfe_pm_domain_on - Enable power domains specific to this VFE. - * @vfe: VFE Device - */ -static int vfe_pm_domain_on(struct vfe_device *vfe) -{ - struct camss *camss = vfe->camss; - - vfe->genpd_link = device_link_add(camss->dev, vfe->genpd, DL_FLAG_STATELESS | - DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); - - if (!vfe->genpd_link) { - dev_err(vfe->camss->dev, "Failed to add VFE#%d to power domain\n", vfe->id); - return -EINVAL; - } - - return 0; -} - static void vfe_violation_read(struct vfe_device *vfe) { u32 violation = readl_relaxed(vfe->base + VFE_0_VIOLATION_STATUS); diff --git a/drivers/media/platform/qcom/camss/camss-vfe-480.c b/drivers/media/platform/qcom/camss/camss-vfe-480.c index a70b8633bb3eb..4652e8b4cff58 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-480.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-480.c @@ -452,41 +452,6 @@ static void vfe_isr_wm_done(struct vfe_device *vfe, u8 wm) spin_unlock_irqrestore(&vfe->output_lock, flags); } -/* - * vfe_pm_domain_off - Disable power domains specific to this VFE. - * @vfe: VFE Device - */ -static void vfe_pm_domain_off(struct vfe_device *vfe) -{ - struct camss *camss = vfe->camss; - - if (vfe->id >= camss->res->vfe_num) - return; - - device_link_del(vfe->genpd_link); -} - -/* - * vfe_pm_domain_on - Enable power domains specific to this VFE. - * @vfe: VFE Device - */ -static int vfe_pm_domain_on(struct vfe_device *vfe) -{ - struct camss *camss = vfe->camss; - - if (vfe->id >= camss->res->vfe_num) - return 0; - - vfe->genpd_link = device_link_add(camss->dev, vfe->genpd, - DL_FLAG_STATELESS | - DL_FLAG_PM_RUNTIME | - DL_FLAG_RPM_ACTIVE); - if (!vfe->genpd_link) - return -EINVAL; - - return 0; -} - /* * vfe_queue_buffer - Add empty buffer * @vid: Video device structure diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c index 94267b9974554..5172eb5612a1c 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -474,6 +474,40 @@ void vfe_isr_reset_ack(struct vfe_device *vfe) complete(&vfe->reset_complete); } +/* + * vfe_pm_domain_off - Disable power domains specific to this VFE. + * @vfe: VFE Device + */ +void vfe_pm_domain_off(struct vfe_device *vfe) +{ + if (!vfe->genpd) + return; + + device_link_del(vfe->genpd_link); + vfe->genpd_link = NULL; +} + +/* + * vfe_pm_domain_on - Enable power domains specific to this VFE. + * @vfe: VFE Device + */ +int vfe_pm_domain_on(struct vfe_device *vfe) +{ + struct camss *camss = vfe->camss; + + if (!vfe->genpd) + return 0; + + vfe->genpd_link = device_link_add(camss->dev, vfe->genpd, + DL_FLAG_STATELESS | + DL_FLAG_PM_RUNTIME | + DL_FLAG_RPM_ACTIVE); + if (!vfe->genpd_link) + return -EINVAL; + + return 0; +} + static int vfe_match_clock_names(struct vfe_device *vfe, struct camss_clock *clock) { diff --git a/drivers/media/platform/qcom/camss/camss-vfe.h b/drivers/media/platform/qcom/camss/camss-vfe.h index c1c50023d4876..992a2103ec44c 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.h +++ b/drivers/media/platform/qcom/camss/camss-vfe.h @@ -203,6 +203,18 @@ int vfe_reset(struct vfe_device *vfe); */ int vfe_disable(struct vfe_line *line); +/* + * vfe_pm_domain_off - Disable power domains specific to this VFE. + * @vfe: VFE Device + */ +void vfe_pm_domain_off(struct vfe_device *vfe); + +/* + * vfe_pm_domain_on - Enable power domains specific to this VFE. + * @vfe: VFE Device + */ +int vfe_pm_domain_on(struct vfe_device *vfe); + extern const struct vfe_hw_ops vfe_ops_4_1; extern const struct vfe_hw_ops vfe_ops_4_7; extern const struct vfe_hw_ops vfe_ops_4_8; From patchwork Fri Nov 3 12:29:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 161258 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp990915vqu; Fri, 3 Nov 2023 05:29:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG95oFStLqTjjospKdhddNX4pkGqAWKyozsTt5HMVimw6tcwgCEBceB6aipFyrv9oopQ8BZ X-Received: by 2002:a05:6a00:21d3:b0:6bc:635a:aad3 with SMTP id t19-20020a056a0021d300b006bc635aaad3mr19897037pfj.9.1699014582200; Fri, 03 Nov 2023 05:29:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699014582; cv=none; d=google.com; s=arc-20160816; b=ONTVGkBMUV6r98aPsPZqFpvkAJ0Da8QgpV1gdwQ4kGA4no1JKW0i/RdFb+Izb/EG+r ZxKOSdZa5SEYBPt874TS0SFESJ+X9m6pUba5Munw/ixeRoZG4cTO4aIRPGy7f7vlpTWX Wpocwj2fY+wvuJKXnemW7KkSJD8sbleIYo3t1oeqbmji/rRbvMtrFB8rtPxYCcztnBMu 5w9uN7jHXPJFXpv9QnsW40smZbqMvWWs7UDCmYYCep9jT/XgrSRJJP0GkvEhr/piR/rs 0vxxZFm51t0HAKhDDXxbili07YHDzV2QwFC1W5NtbELLheNOP1IYOuIWnyLXtyv8cs6I oiqg== 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=Kfmsv1+9a7xxjyHODu3lURwTZ23LFgQq1tCajTllXGQ=; fh=+21+21gNft/7To99MfcGJu9QkWyyZ7J1aCqrKBAZjFw=; b=SmQo1HWDOwGDuM+wyeppoqvM9W24z9CwMDbTMMXgNsAFutiew4SJHcZfQPCaXUBwJR rjfkweCG/meA2xyDFhEk7DVedDqAKYBVm8j8UC4OknbDIOj0KVIez7U2Bpi1y4Mj+ou+ f41UR8OoirqQvCsngozfpEd1/6TUCAEUq8r3EDaHef2GbieiJbQE1NtmW2mmTXcrL4Jt YNt5Mpf5a0aMB1JtPQ7YHs9oa+iJUE9aGpCfhqdA79JbkLv6Yjf25wpa+22Z8V4MHYr1 XhE2uM87zGrgSfjFWsy3DNqF/a4S0H+sOeT4CWmAGRbnlAoMSioE8tJhNB+H1uRVBSlh iHdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hNfv1JGp; 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id i129-20020a639d87000000b005b87be63da6si1464137pgd.488.2023.11.03.05.29.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 05:29:42 -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=hNfv1JGp; 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 196B182B4867; Fri, 3 Nov 2023 05:29:41 -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 S1376497AbjKCM30 (ORCPT + 36 others); Fri, 3 Nov 2023 08:29:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376553AbjKCM3U (ORCPT ); Fri, 3 Nov 2023 08:29:20 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEB5FD5B for ; Fri, 3 Nov 2023 05:29:07 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-408425c7c10so14914175e9.0 for ; Fri, 03 Nov 2023 05:29:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699014546; x=1699619346; 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=Kfmsv1+9a7xxjyHODu3lURwTZ23LFgQq1tCajTllXGQ=; b=hNfv1JGpj5M/h6XSF9pm1tlKSQKiMhZHAaDy/fCYFbNmPknyUPlPUyVH/Mdtajxzx7 WIoC82Hv910kMCKIS/AXRiOUAEZUUM2y8Rb8uFKlRVWzbGxJIy9I4o3sbgvAK1X/WCMg OZfcQDCJNWoqGhV3akDq+fBRf9twxhoWyPNCP8spEYSwsAFgoyZWW4kKXEvJnZwp2guC OF14Ygo0sNpp9oHjr7NXM+4BECO8Fsv8wlOcQBR3tlgtqjqTLrfbz+BaXFvJupEtUXia d1VJq/dA2TDaKBosGn3AmIlB2XhpUdN7j+4dY6BUgBMSrPgftMIPxe+zm5ztepb2LSdG F+8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699014546; x=1699619346; 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=Kfmsv1+9a7xxjyHODu3lURwTZ23LFgQq1tCajTllXGQ=; b=EaQtVScD/4mqezGULdMLAxs5j5g/xoRqSZymeM3uIvM4hmJ1y3NymH2Lb2GES64T85 xXUAX6P+BVT6Pz7gSQiesjiAvLYNTdIf7A+UtmF5jiztJ4X47YImkRjsMELgNQYx/yAM /FU4MJH3hWJlZ+CW+DnRe8JRTBzYm7+lsjYCmYGwLqmHzXRAEDD4kjOFqwlNetOoXOhF Z5b/bzL7mYy9xHCvo1cINMITLqXG91iy6PrFqqqWWkzaNx3e+4bBU5YGXV49Fi6SMdNa 6clZ2M1lSDL4/XWHjFtzrO9h55XQFw6ggW1TVdmUBOOWnEkbcQp1DDxYUT20nz2z5q/9 J52A== X-Gm-Message-State: AOJu0YzdaAAe9aEdty9XD5EwzT7VFI+hx2Fa3/BurK2klbLJTm800ca1 rV0gKn3qh06PHYTHdi0f+ixTbw== X-Received: by 2002:a05:600c:4748:b0:408:53d4:52dd with SMTP id w8-20020a05600c474800b0040853d452ddmr17182240wmo.22.1699014546138; Fri, 03 Nov 2023 05:29:06 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 05:29:05 -0700 (PDT) From: Bryan O'Donoghue Date: Fri, 03 Nov 2023 12:29:01 +0000 Subject: [PATCH v4 4/7] media: qcom: camss: Move VFE power-domain specifics into vfe.c MIME-Version: 1.0 Message-Id: <20231103-b4-camss-named-power-domains-v4-4-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:41 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781545914127064347 X-GMAIL-MSGID: 1781545914127064347 Moving the location of the hooks to VFE power domains has several advantages. 1. Separation of concerns and functional decomposition. vfe.c should be responsible for and know best how manage power-domains for a VFE, excising from camss.c follows this principle. 2. Embedding a pointer to genpd in struct camss_vfe{} meas that we can dispense with a bunch of kmalloc array inside of camss.c. 3. Splitting up titan top gdsc from vfe/ife gdsc provides a base for breaking up magic indexes in dtsi. Suggested-by: Matti Lehtimäki 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-vfe.h | 2 + drivers/media/platform/qcom/camss/camss.c | 68 +++++++++++++++------------ drivers/media/platform/qcom/camss/camss.h | 4 +- 4 files changed, 63 insertions(+), 35 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c index 5172eb5612a1c..defff24f07ce3 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -1381,8 +1382,13 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe, if (!res->line_num) return -EINVAL; - if (res->has_pd) - vfe->genpd = camss->genpd[id]; + if (res->has_pd) { + vfe->genpd = dev_pm_domain_attach_by_id(camss->dev, id); + if (IS_ERR(vfe->genpd)) { + ret = PTR_ERR(vfe->genpd); + return ret; + } + } vfe->line_num = res->line_num; vfe->ops->subdev_init(dev, vfe); @@ -1506,6 +1512,20 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe, return 0; } +/* + * msm_vfe_genpd_cleanup - Cleanup VFE genpd linkages + * @vfe: VFE device + * + */ +void msm_vfe_genpd_cleanup(struct vfe_device *vfe) +{ + if (vfe->genpd_link) + device_link_del(vfe->genpd_link); + + if (vfe->genpd) + dev_pm_domain_detach(vfe->genpd, true); +} + /* * vfe_link_setup - Setup VFE connections * @entity: Pointer to media entity structure diff --git a/drivers/media/platform/qcom/camss/camss-vfe.h b/drivers/media/platform/qcom/camss/camss-vfe.h index 992a2103ec44c..cdbe59d8d437e 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.h +++ b/drivers/media/platform/qcom/camss/camss-vfe.h @@ -159,6 +159,8 @@ struct camss_subdev_resources; int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe, const struct camss_subdev_resources *res, u8 id); +void msm_vfe_genpd_cleanup(struct vfe_device *vfe); + int msm_vfe_register_entities(struct vfe_device *vfe, struct v4l2_device *v4l2_dev); diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c index ed01a3ac7a38e..f10a47f1aee7d 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -1487,7 +1487,9 @@ static const struct media_device_ops camss_media_ops = { static int camss_configure_pd(struct camss *camss) { struct device *dev = camss->dev; + const struct camss_resources *res = camss->res; int i; + int vfepd_num; int ret; camss->genpd_num = of_count_phandle_with_args(dev->of_node, @@ -1506,45 +1508,42 @@ static int camss_configure_pd(struct camss *camss) if (camss->genpd_num == 1) return 0; - camss->genpd = devm_kmalloc_array(dev, camss->genpd_num, - sizeof(*camss->genpd), GFP_KERNEL); - if (!camss->genpd) - return -ENOMEM; + /* count the # of VFEs which have flagged power-domain */ + for (vfepd_num = i = 0; i < camss->vfe_total_num; i++) { + if (res->vfe_res[i].has_pd) + vfepd_num++; + } - camss->genpd_link = devm_kmalloc_array(dev, camss->genpd_num, - sizeof(*camss->genpd_link), - GFP_KERNEL); - if (!camss->genpd_link) - return -ENOMEM; + /* + * If the number of power-domains is greater than the number of VFEs + * then the additional power-domain is for the entire CAMSS block the + * 'top' power-domain. + */ + if (camss->genpd_num <= vfepd_num) + 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. */ - for (i = 0; i < camss->genpd_num; i++) { - camss->genpd[i] = dev_pm_domain_attach_by_id(camss->dev, i); - if (IS_ERR(camss->genpd[i])) { - ret = PTR_ERR(camss->genpd[i]); - goto fail_pm; - } + camss->genpd = dev_pm_domain_attach_by_id(camss->dev, camss->genpd_num - 1); + if (IS_ERR(camss->genpd)) { + ret = PTR_ERR(camss->genpd); + goto fail_pm; } - - if (i > camss->res->vfe_num) { - camss->genpd_link[i - 1] = device_link_add(camss->dev, camss->genpd[i - 1], - DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME | - DL_FLAG_RPM_ACTIVE); - if (!camss->genpd_link[i - 1]) { - ret = -EINVAL; - goto fail_pm; - } + camss->genpd_link = device_link_add(camss->dev, camss->genpd, + DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME | + DL_FLAG_RPM_ACTIVE); + if (!camss->genpd_link) { + ret = -EINVAL; + goto fail_pm; } return 0; fail_pm: - for (--i ; i >= 0; i--) - dev_pm_domain_detach(camss->genpd[i], true); + dev_pm_domain_detach(camss->genpd, true); return ret; } @@ -1566,18 +1565,25 @@ static int camss_icc_get(struct camss *camss) return 0; } -static void camss_genpd_cleanup(struct camss *camss) +static void camss_genpd_subdevice_cleanup(struct camss *camss) { int i; + for (i = 0; i < camss->vfe_total_num; i++) + msm_vfe_genpd_cleanup(&camss->vfe[i]); +} + +static void camss_genpd_cleanup(struct camss *camss) +{ if (camss->genpd_num == 1) return; - if (camss->genpd_num > camss->res->vfe_num) - device_link_del(camss->genpd_link[camss->genpd_num - 1]); + if (camss->genpd_link) + device_link_del(camss->genpd_link); + + dev_pm_domain_detach(camss->genpd, true); - for (i = 0; i < camss->genpd_num; i++) - dev_pm_domain_detach(camss->genpd[i], true); + camss_genpd_subdevice_cleanup(camss); } /* diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h index b854cff1774d4..1ba824a2cb76c 100644 --- a/drivers/media/platform/qcom/camss/camss.h +++ b/drivers/media/platform/qcom/camss/camss.h @@ -107,8 +107,8 @@ struct camss { struct vfe_device *vfe; atomic_t ref_count; int genpd_num; - struct device **genpd; - struct device_link **genpd_link; + struct device *genpd; + struct device_link *genpd_link; struct icc_path *icc_path[ICC_SM8250_COUNT]; const struct camss_resources *res; unsigned int vfe_total_num; From patchwork Fri Nov 3 12:29:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 161261 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp990988vqu; Fri, 3 Nov 2023 05:29:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGHDEh2MOEMbf7iH/eAZJ/8nr/kSOPAz3gzokFM2GiMWWjhPzjgFxaxEWCxF9ThjQHPTAjt X-Received: by 2002:a17:90a:4922:b0:27d:1862:a494 with SMTP id c31-20020a17090a492200b0027d1862a494mr17638087pjh.11.1699014591632; 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 Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id nl11-20020a17090b384b00b002800f26bfdasi1621126pjb.12.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 C13D181373E9; 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 S1377157AbjKCM3h (ORCPT + 36 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 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) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781545924345281235 X-GMAIL-MSGID: 1781545924345281235 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; From patchwork Fri Nov 3 12:29:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 161260 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp990960vqu; Fri, 3 Nov 2023 05:29:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGjHKaLJ1/9DKQokiIyqQW7p7PEbYD4jGct1Eb5Q5ZZryByfE/GZ9s3xV5/nGeXxowc1Be+ X-Received: by 2002:a17:902:d2c1:b0:1cc:3908:2ca7 with SMTP id n1-20020a170902d2c100b001cc39082ca7mr15531017plc.33.1699014588131; Fri, 03 Nov 2023 05:29:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699014588; cv=none; d=google.com; s=arc-20160816; b=VG/oOwbRY/QuDruxWR0pnQiOlp0A0VbH6plH8mLUhrzklSYrzE77MWcirCBgmTx50t YurLOqR/ajGKdrKTSHgGZoTaM7/7DWl8Td8IuEXfhtytZw0MNBmBoMxfQ0GkzJmZE6dH N3gk4RQ6Zqe8dI4RsYDGKV9ipoIEuRIknBkNT7BEZFm8/6+vN9vuh8WwiarZlry4C/Gf hJHXRKSqvc7DNW/QsW8Mz/GwdGOChhvApF/L/l64JDT/2cQMMpPTk+V5xZsxYvAEhGsH wJGzJ0O2BN/IBTnuy2RpkvsC0EakqIyGIt/377/fGYk0+cIhYUZCVoEoLB/0qsUc90XC zSrg== 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=96yZtHNTLjZ6izlRdJ3xJStRMszue7FUw4nVvXQ6hPA=; fh=+21+21gNft/7To99MfcGJu9QkWyyZ7J1aCqrKBAZjFw=; b=MN520ffKd51D4Za/uhO7yFy5Bwv9iYTZh2zobhAc4zNFXCoe/ZTh5eIvlJd7u++C37 YYXWRpySIWoAEeXx4GQz6lr+ACv2nVwTitZEO+DHQa36YfZyzYOLVlnIHTvC8jRnm0ej nqwP6ZmZjgDQS/aciYjpLDJrG+Ej1yPrv4ZbCtULuzubSaO/0mSIDq0fEgfAkkw95C09 MyofdI0J6W3v+CHUtk8VRW+V6d7Uqzr1KuIyofUm3x+ctZmiJjfkjhVX7rQYbR3S7a+E 9thiBmdsAdY1QzlO61mQfvEsOJ7U1WbCJ/YKP0EMSvKATP3dqJKLOGd6WxvvhUPNzRq/ i/FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V0x0JLWc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id l8-20020a170903120800b001b973681493si1469986plh.16.2023.11.03.05.29.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 05:29:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V0x0JLWc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 47D528312F98; Fri, 3 Nov 2023 05:29:47 -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 S1376656AbjKCM3d (ORCPT + 36 others); Fri, 3 Nov 2023 08:29:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376489AbjKCM3U (ORCPT ); Fri, 3 Nov 2023 08:29:20 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72F5FD53 for ; Fri, 3 Nov 2023 05:29:10 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2c515527310so28191641fa.2 for ; Fri, 03 Nov 2023 05:29:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699014548; x=1699619348; 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=96yZtHNTLjZ6izlRdJ3xJStRMszue7FUw4nVvXQ6hPA=; b=V0x0JLWcpxqySbDac6+dOLoqDzHgfRIX1jPl/lAq9SSEZ6vSATBWn437Lr5CJ15MuU KXpU0os1cq8At/wZ0K8mbkQNOAxQuZal5TteVq5boK4gDIdtm9akaYHHvDYE/SRKG3cf cj5k1/HFj2c5UmcWjOd4asG7Iw5PizUY0T5AYR7Uezsng+/w+V8sa+NCoRlLxHoT9WaK VHklErTxY+PFBYjFEZ3xZrz69uRpC7DYKWb9E9/IQILL2KTkByfwTID8LQc5A4U5KGmy AgVV778qqEv64RxBIehk3sBxVu1PJBRw2w8/plloBj4Ix2vTaOyR6zCv/jOp0OMxLQdo eHrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699014548; x=1699619348; 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=96yZtHNTLjZ6izlRdJ3xJStRMszue7FUw4nVvXQ6hPA=; b=ngIP021bq069szXve1YbBqhxD0Ea9yCy8yLFz5zSofrADILMQYIRkpmiiy7+XkCXHG 8aROj3JFoZ9fdOSTPgLAS8mAlhtODagzDVrIC4a6Cu38xmxMZM3Eux8GIl2yE7ugjwKF zGd3ic81WH3CM9XD+P2YkVKqU8lGr6Y5GUg4fWYTNtHuFVke6nZyJ+4qbnf6wmFqMSkb uD0yKYESI4iXBSu6s6XiGA40YasanHaJKEzLaoNwwflf9c3fO9uMh3Pms8/kYMVNkSor pDlmDeU6+9nN6j9OkHghTwpS3OdwFqoHQLkT9nJ/L4uH+W10FSZlfP5/qRudkfjPxRqW Lsew== X-Gm-Message-State: AOJu0YyWd6lX19NS3l3Sh0AY6GNkXn5G8CP+G7GAO3i+pCS1yJNREHPx sMAjVNs/7IFw/AJe5ykZ2L/7xQ== X-Received: by 2002:a05:651c:21a:b0:2c5:169f:ff02 with SMTP id y26-20020a05651c021a00b002c5169fff02mr18488505ljn.20.1699014548605; Fri, 03 Nov 2023 05:29:08 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 05:29:08 -0700 (PDT) From: Bryan O'Donoghue Date: Fri, 03 Nov 2023 12:29:03 +0000 Subject: [PATCH v4 6/7] media: qcom: camss: Flag VFE-lites to support more VFEs MIME-Version: 1.0 Message-Id: <20231103-b4-camss-named-power-domains-v4-6-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:47 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781545920641017546 X-GMAIL-MSGID: 1781545920641017546 From: Matti Lehtimäki Some platforms such as SC7280 have three VFEs and two VFE-lites. Current code has hard-coded two as the maximum number of VFEs. Remove the hard-coded maximum number of VFEs to handle all possible combinations of VFEs and VFE-lites. Signed-off-by: Matti Lehtimäki Signed-off-by: Bryan O'Donoghue Reviewed-by: Konrad Dybcio --- drivers/media/platform/qcom/camss/camss-vfe-480.c | 33 +++++++++++------------ drivers/media/platform/qcom/camss/camss-vfe.c | 5 ++++ drivers/media/platform/qcom/camss/camss-vfe.h | 10 +++++++ drivers/media/platform/qcom/camss/camss.c | 26 +++++++++--------- drivers/media/platform/qcom/camss/camss.h | 3 +-- 5 files changed, 44 insertions(+), 33 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe-480.c b/drivers/media/platform/qcom/camss/camss-vfe-480.c index 4652e8b4cff58..dc2735476c823 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-480.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-480.c @@ -15,31 +15,28 @@ #include "camss.h" #include "camss-vfe.h" -/* VFE 2/3 are lite and have a different register layout */ -#define IS_LITE (vfe->id >= 2 ? 1 : 0) - #define VFE_HW_VERSION (0x00) -#define VFE_GLOBAL_RESET_CMD (IS_LITE ? 0x0c : 0x1c) -#define GLOBAL_RESET_HW_AND_REG (IS_LITE ? BIT(1) : BIT(0)) +#define VFE_GLOBAL_RESET_CMD (vfe_is_lite(vfe) ? 0x0c : 0x1c) +#define GLOBAL_RESET_HW_AND_REG (vfe_is_lite(vfe) ? BIT(1) : BIT(0)) -#define VFE_REG_UPDATE_CMD (IS_LITE ? 0x20 : 0x34) +#define VFE_REG_UPDATE_CMD (vfe_is_lite(vfe) ? 0x20 : 0x34) static inline int reg_update_rdi(struct vfe_device *vfe, int n) { - return IS_LITE ? BIT(n) : BIT(1 + (n)); + return vfe_is_lite(vfe) ? BIT(n) : BIT(1 + (n)); } #define REG_UPDATE_RDI reg_update_rdi -#define VFE_IRQ_CMD (IS_LITE ? 0x24 : 0x38) +#define VFE_IRQ_CMD (vfe_is_lite(vfe) ? 0x24 : 0x38) #define IRQ_CMD_GLOBAL_CLEAR BIT(0) -#define VFE_IRQ_MASK(n) ((IS_LITE ? 0x28 : 0x3c) + (n) * 4) -#define IRQ_MASK_0_RESET_ACK (IS_LITE ? BIT(17) : BIT(0)) -#define IRQ_MASK_0_BUS_TOP_IRQ (IS_LITE ? BIT(4) : BIT(7)) -#define VFE_IRQ_CLEAR(n) ((IS_LITE ? 0x34 : 0x48) + (n) * 4) -#define VFE_IRQ_STATUS(n) ((IS_LITE ? 0x40 : 0x54) + (n) * 4) +#define VFE_IRQ_MASK(n) ((vfe_is_lite(vfe) ? 0x28 : 0x3c) + (n) * 4) +#define IRQ_MASK_0_RESET_ACK (vfe_is_lite(vfe) ? BIT(17) : BIT(0)) +#define IRQ_MASK_0_BUS_TOP_IRQ (vfe_is_lite(vfe) ? BIT(4) : BIT(7)) +#define VFE_IRQ_CLEAR(n) ((vfe_is_lite(vfe) ? 0x34 : 0x48) + (n) * 4) +#define VFE_IRQ_STATUS(n) ((vfe_is_lite(vfe) ? 0x40 : 0x54) + (n) * 4) -#define BUS_REG_BASE (IS_LITE ? 0x1a00 : 0xaa00) +#define BUS_REG_BASE (vfe_is_lite(vfe) ? 0x1a00 : 0xaa00) #define VFE_BUS_WM_CGC_OVERRIDE (BUS_REG_BASE + 0x08) #define WM_CGC_OVERRIDE_ALL (0x3FFFFFF) @@ -49,13 +46,13 @@ static inline int reg_update_rdi(struct vfe_device *vfe, int n) #define VFE_BUS_IRQ_MASK(n) (BUS_REG_BASE + 0x18 + (n) * 4) static inline int bus_irq_mask_0_rdi_rup(struct vfe_device *vfe, int n) { - return IS_LITE ? BIT(n) : BIT(3 + (n)); + return vfe_is_lite(vfe) ? BIT(n) : BIT(3 + (n)); } #define BUS_IRQ_MASK_0_RDI_RUP bus_irq_mask_0_rdi_rup static inline int bus_irq_mask_0_comp_done(struct vfe_device *vfe, int n) { - return IS_LITE ? BIT(4 + (n)) : BIT(6 + (n)); + return vfe_is_lite(vfe) ? BIT(4 + (n)) : BIT(6 + (n)); } #define BUS_IRQ_MASK_0_COMP_DONE bus_irq_mask_0_comp_done @@ -90,8 +87,8 @@ static inline int bus_irq_mask_0_comp_done(struct vfe_device *vfe, int n) /* for titan 480, each bus client is hardcoded to a specific path * and each bus client is part of a hardcoded "comp group" */ -#define RDI_WM(n) ((IS_LITE ? 0 : 23) + (n)) -#define RDI_COMP_GROUP(n) ((IS_LITE ? 0 : 11) + (n)) +#define RDI_WM(n) ((vfe_is_lite(vfe) ? 0 : 23) + (n)) +#define RDI_COMP_GROUP(n) ((vfe_is_lite(vfe) ? 0 : 11) + (n)) #define MAX_VFE_OUTPUT_LINES 4 diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c index 123e5ead7602d..50929c3cbb831 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -1742,3 +1742,8 @@ void msm_vfe_unregister_entities(struct vfe_device *vfe) media_entity_cleanup(&sd->entity); } } + +inline bool vfe_is_lite(struct vfe_device *vfe) +{ + return vfe->camss->res->vfe_res[vfe->id].is_lite; +} diff --git a/drivers/media/platform/qcom/camss/camss-vfe.h b/drivers/media/platform/qcom/camss/camss-vfe.h index cdbe59d8d437e..e75d5cc0bf47a 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.h +++ b/drivers/media/platform/qcom/camss/camss-vfe.h @@ -226,4 +226,14 @@ extern const struct vfe_hw_ops vfe_ops_480; int vfe_get(struct vfe_device *vfe); void vfe_put(struct vfe_device *vfe); +/* + * vfe_is_lite - Return if VFE is VFE lite. + * @vfe: VFE Device + * + * Some VFE lites have a different register layout. + * + * Return whether VFE is VFE lite + */ +inline bool vfe_is_lite(struct vfe_device *vfe); + #endif /* QC_MSM_CAMSS_VFE_H */ diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c index d565260fee0d6..f5226eb8bf4fc 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -706,6 +706,7 @@ static const struct camss_subdev_resources vfe_res_845[] = { { 384000000 } }, .reg = { "vfe_lite" }, .interrupt = { "vfe_lite" }, + .is_lite = true, .line_num = 4, .ops = &vfe_ops_170 } @@ -886,6 +887,7 @@ static const struct camss_subdev_resources vfe_res_8250[] = { { 0 } }, .reg = { "vfe_lite0" }, .interrupt = { "vfe_lite0" }, + .is_lite = true, .line_num = 4, .ops = &vfe_ops_480 }, @@ -905,6 +907,7 @@ static const struct camss_subdev_resources vfe_res_8250[] = { { 0 } }, .reg = { "vfe_lite1" }, .interrupt = { "vfe_lite1" }, + .is_lite = true, .line_num = 4, .ops = &vfe_ops_480 }, @@ -1204,7 +1207,7 @@ static int camss_init_subdevices(struct camss *camss) } /* note: SM8250 requires VFE to be initialized before CSID */ - for (i = 0; i < camss->vfe_total_num; i++) { + for (i = 0; i < camss->res->vfe_num; i++) { ret = msm_vfe_subdev_init(camss, &camss->vfe[i], &res->vfe_res[i], i); if (ret < 0) { @@ -1276,7 +1279,7 @@ static int camss_register_entities(struct camss *camss) goto err_reg_ispif; } - for (i = 0; i < camss->vfe_total_num; i++) { + for (i = 0; i < camss->res->vfe_num; i++) { ret = msm_vfe_register_entities(&camss->vfe[i], &camss->v4l2_dev); if (ret < 0) { @@ -1348,7 +1351,7 @@ static int camss_register_entities(struct camss *camss) } } else { for (i = 0; i < camss->res->csid_num; i++) - for (k = 0; k < camss->vfe_total_num; k++) + for (k = 0; k < camss->res->vfe_num; k++) for (j = 0; j < camss->vfe[k].line_num; j++) { struct v4l2_subdev *csid = &camss->csid[i].subdev; struct v4l2_subdev *vfe = &camss->vfe[k].line[j].subdev; @@ -1372,7 +1375,7 @@ static int camss_register_entities(struct camss *camss) return 0; err_link: - i = camss->vfe_total_num; + i = camss->res->vfe_num; err_reg_vfe: for (i--; i >= 0; i--) msm_vfe_unregister_entities(&camss->vfe[i]); @@ -1411,7 +1414,7 @@ static void camss_unregister_entities(struct camss *camss) msm_ispif_unregister_entities(camss->ispif); - for (i = 0; i < camss->vfe_total_num; i++) + for (i = 0; i < camss->res->vfe_num; i++) msm_vfe_unregister_entities(&camss->vfe[i]); } @@ -1509,7 +1512,7 @@ static int camss_configure_pd(struct camss *camss) return 0; /* count the # of VFEs which have flagged power-domain */ - for (vfepd_num = i = 0; i < camss->vfe_total_num; i++) { + for (vfepd_num = i = 0; i < camss->res->vfe_num; i++) { if (res->vfe_res[i].has_pd) vfepd_num++; } @@ -1585,7 +1588,7 @@ static void camss_genpd_subdevice_cleanup(struct camss *camss) { int i; - for (i = 0; i < camss->vfe_total_num; i++) + for (i = 0; i < camss->res->vfe_num; i++) msm_vfe_genpd_cleanup(&camss->vfe[i]); } @@ -1642,8 +1645,7 @@ static int camss_probe(struct platform_device *pdev) return -ENOMEM; } - camss->vfe_total_num = camss->res->vfe_num + camss->res->vfe_lite_num; - camss->vfe = devm_kcalloc(dev, camss->vfe_total_num, + camss->vfe = devm_kcalloc(dev, camss->res->vfe_num, sizeof(*camss->vfe), GFP_KERNEL); if (!camss->vfe) return -ENOMEM; @@ -1801,8 +1803,7 @@ static const struct camss_resources sdm845_resources = { .vfe_res = vfe_res_845, .csiphy_num = ARRAY_SIZE(csiphy_res_845), .csid_num = ARRAY_SIZE(csid_res_845), - .vfe_num = 2, - .vfe_lite_num = 1, + .vfe_num = ARRAY_SIZE(vfe_res_845), }; static const struct camss_resources sm8250_resources = { @@ -1814,8 +1815,7 @@ static const struct camss_resources sm8250_resources = { .icc_path_num = ARRAY_SIZE(icc_res_sm8250), .csiphy_num = ARRAY_SIZE(csiphy_res_8250), .csid_num = ARRAY_SIZE(csid_res_8250), - .vfe_num = 2, - .vfe_lite_num = 2, + .vfe_num = ARRAY_SIZE(vfe_res_8250), }; static const struct of_device_id camss_dt_match[] = { diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h index cd8186fe1797b..a0c2dcc779f05 100644 --- a/drivers/media/platform/qcom/camss/camss.h +++ b/drivers/media/platform/qcom/camss/camss.h @@ -51,6 +51,7 @@ struct camss_subdev_resources { char *pd_name; u8 line_num; bool has_pd; + bool is_lite; const void *ops; }; @@ -95,7 +96,6 @@ struct camss_resources { const unsigned int csiphy_num; const unsigned int csid_num; const unsigned int vfe_num; - const unsigned int vfe_lite_num; }; struct camss { @@ -113,7 +113,6 @@ struct camss { struct device_link *genpd_link; struct icc_path *icc_path[ICC_SM8250_COUNT]; const struct camss_resources *res; - unsigned int vfe_total_num; }; struct camss_camera_interface { From patchwork Fri Nov 3 12:29:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 161259 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp990937vqu; Fri, 3 Nov 2023 05:29:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHU16nPfkXhp/eqkchqZQVpvBd2rm8oGQp0tHCCF/tMw8gXS/+QOFt+jlTZ3D8PlyWUv4dx X-Received: by 2002:a05:6a20:2307:b0:174:373b:4381 with SMTP id n7-20020a056a20230700b00174373b4381mr14099713pzc.49.1699014584839; Fri, 03 Nov 2023 05:29:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699014584; cv=none; d=google.com; s=arc-20160816; b=e0ejY/eUWXoYoC+eKMdTJFwp4g08klp08j6JP1uegcBuPnkLxPMLhbxb+ven70frLy Ej//fOTGic/WFRjTRE96tkSBM9hYD2ytNl4lhUvTqbYc1BOE+LAgawhfurvgwVPllF6g YOvNcDyg+dMSeYezFb30NL/Cl4Solg7K0wrHzN8uxQhFQVhTdLrOgVLPTe7Ac0wktxcn IVaeySikURNJPNTUw+LCAyTHpzvEP9oqZrV0pIRV5FLP9QA69t0nN+HOkMGo/EMpoP8I vONxDoCABDSJoIabMwBmr6PkAYyKueEWMbQbP1ieaA1b58gUvZ2yHJjCXS6pBvoCHiVP hZpA== 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=A5e6ystGbmI0nEkqiwKt50qKqvjyJaFKyap2sSy1xpA=; fh=+21+21gNft/7To99MfcGJu9QkWyyZ7J1aCqrKBAZjFw=; b=CdcuM0CuDWj0Ny+HT7kw3j9WykuzsSbPdbnl9Bnx8ILTyVnh67NsDdqZCE++i8db+p tFAEWwhH5Eafkmb3As9ZDVpSakoE7UH7AyjxvS0uz2dM/kr/NRDn0Gt+VFVqt3w4ZAxQ W9EmgJ+cA2amXHowcTjBi3+Weija24eMoCw5pr3Zo98+NFV78v5ODDmf1eKZBVVZrlu2 eR7rMDHfEHphFTTAg0W79ONwuvcoA9Nrifhx/sQSAd/rWj3cvkdFB7hEGx31tunqZYEW 1xd6NgxwZujI+vhqhnYL4pGecLfWAGsMPwawhG4Lkzw8ekJUg0dfTSybtH1DCeGKjbIL o4/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qJu9DniQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id v202-20020a6361d3000000b005ac44f928e4si1388841pgb.152.2023.11.03.05.29.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 05:29:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qJu9DniQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 65C088312F91; Fri, 3 Nov 2023 05:29:43 -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 S1376671AbjKCM33 (ORCPT + 36 others); Fri, 3 Nov 2023 08:29:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376499AbjKCM3V (ORCPT ); Fri, 3 Nov 2023 08:29:21 -0400 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FB72184 for ; Fri, 3 Nov 2023 05:29:11 -0700 (PDT) Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2c594196344so27068231fa.3 for ; Fri, 03 Nov 2023 05:29:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699014550; x=1699619350; 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=A5e6ystGbmI0nEkqiwKt50qKqvjyJaFKyap2sSy1xpA=; b=qJu9DniQ8gCLQXeGzU4agasudpouNHUZUUvgSAvAlrjjEbXk0vF8VOnigIRhsybhyu p6WMScll49ut2x8jM94GlpIEJRtdlyI0KsozOCy5kqO86UfyNpIrjqD3PJ8XW4Fk4tk6 p/Q6H16EErLDtSfMb4JgUtXr6dIU1KR52ah5LxVjFilxmAxHt0YvPdATPZwKqgvOczYr jQVSYucUCJ9zjqz/uff9qHMQBQi9GiUz4glhJo6bCJ0bfxDkNZiRpgjwybUWszz4Xq+3 607pjPNepdpjULGWPp0sKy9Y0Zhm26Ouk1VaA5TtA0Zp9gVpMJI+H6NPi7lHdeFCQoG2 hZaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699014550; x=1699619350; 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=A5e6ystGbmI0nEkqiwKt50qKqvjyJaFKyap2sSy1xpA=; b=Y+YJulojqgEVocAZ/q1rxt7gZRcfgdLM0yBYlIeLXbadscoEIIWa7JWvDmyewt2EHA ugcl+yqPUUuHfhrcVoUEF4NnNvEdjfMqIf31Ubeig10FRa+/BOsPt28p2go9kldXmesr DFu9sMseLnpcybikRRpLkcATvPsObP7SRyy0aKJ0dbq/HGBj8wZfhMINPSimNRRAmwP1 drk/VfL3oDy2fFZPXzp6vNhvsmoM2vbmBt58Ufjauy21scPNTzE6yfUfMfs572axFsaD NQxxRUhORlRziJUJm1eBELxiADPq9EwQgspxufW94R/hF08ljk1w1hkPHsugbzVv6S5L RFCQ== X-Gm-Message-State: AOJu0YynEq0vZKKmJFcpDWTanQQyqfvj/GdCZImGhecW3zFJ9doFF5Nd USqd2m++PyLMa5qN2Jp493WWcw== X-Received: by 2002:a2e:97d1:0:b0:2c5:2eaa:5397 with SMTP id m17-20020a2e97d1000000b002c52eaa5397mr15816719ljj.11.1699014549852; Fri, 03 Nov 2023 05:29:09 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 05:29:09 -0700 (PDT) From: Bryan O'Donoghue Date: Fri, 03 Nov 2023 12:29:04 +0000 Subject: [PATCH v4 7/7] media: qcom: camss: Flag CSID-lites to support more CSIDs MIME-Version: 1.0 Message-Id: <20231103-b4-camss-named-power-domains-v4-7-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=ham 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:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781545917040689219 X-GMAIL-MSGID: 1781545917040689219 From: Matti Lehtimäki Some platforms such as SC7280 have 3 CSIDs and 2 CSID-lites but current code has hardcoded 2 as the maximum number of CSIDs. Remove the hardcoded maximum number of VFEs to handle all possible combinations of CSIDs and CSID-lites. Signed-off-by: Matti Lehtimäki Signed-off-by: Bryan O'Donoghue --- .../media/platform/qcom/camss/camss-csid-gen2.c | 31 +++++++++++----------- drivers/media/platform/qcom/camss/camss-csid.c | 5 ++++ drivers/media/platform/qcom/camss/camss-csid.h | 7 +++++ drivers/media/platform/qcom/camss/camss.c | 3 +++ 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-csid-gen2.c b/drivers/media/platform/qcom/camss/camss-csid-gen2.c index 05ff5fa8095a8..b11de4797ccae 100644 --- a/drivers/media/platform/qcom/camss/camss-csid-gen2.c +++ b/drivers/media/platform/qcom/camss/camss-csid-gen2.c @@ -21,7 +21,6 @@ * interface support. As a result of that it has an * alternate register layout. */ -#define IS_LITE (csid->id >= 2 ? 1 : 0) #define CSID_HW_VERSION 0x0 #define HW_VERSION_STEPPING 0 @@ -35,13 +34,13 @@ #define CSID_CSI2_RX_IRQ_MASK 0x24 #define CSID_CSI2_RX_IRQ_CLEAR 0x28 -#define CSID_CSI2_RDIN_IRQ_STATUS(rdi) ((IS_LITE ? 0x30 : 0x40) \ +#define CSID_CSI2_RDIN_IRQ_STATUS(rdi) ((csid_is_lite(csid) ? 0x30 : 0x40) \ + 0x10 * (rdi)) -#define CSID_CSI2_RDIN_IRQ_MASK(rdi) ((IS_LITE ? 0x34 : 0x44) \ +#define CSID_CSI2_RDIN_IRQ_MASK(rdi) ((csid_is_lite(csid) ? 0x34 : 0x44) \ + 0x10 * (rdi)) -#define CSID_CSI2_RDIN_IRQ_CLEAR(rdi) ((IS_LITE ? 0x38 : 0x48) \ +#define CSID_CSI2_RDIN_IRQ_CLEAR(rdi) ((csid_is_lite(csid) ? 0x38 : 0x48) \ + 0x10 * (rdi)) -#define CSID_CSI2_RDIN_IRQ_SET(rdi) ((IS_LITE ? 0x3C : 0x4C) \ +#define CSID_CSI2_RDIN_IRQ_SET(rdi) ((csid_is_lite(csid) ? 0x3C : 0x4C) \ + 0x10 * (rdi)) #define CSID_TOP_IRQ_STATUS 0x70 @@ -73,7 +72,7 @@ #define CGC_MODE_DYNAMIC_GATING 0 #define CGC_MODE_ALWAYS_ON 1 -#define CSID_RDI_CFG0(rdi) ((IS_LITE ? 0x200 : 0x300) \ +#define CSID_RDI_CFG0(rdi) ((csid_is_lite(csid) ? 0x200 : 0x300) \ + 0x100 * (rdi)) #define RDI_CFG0_BYTE_CNTR_EN 0 #define RDI_CFG0_FORMAT_MEASURE_EN 1 @@ -98,32 +97,32 @@ #define RDI_CFG0_PACKING_FORMAT 30 #define RDI_CFG0_ENABLE 31 -#define CSID_RDI_CFG1(rdi) ((IS_LITE ? 0x204 : 0x304)\ +#define CSID_RDI_CFG1(rdi) ((csid_is_lite(csid) ? 0x204 : 0x304)\ + 0x100 * (rdi)) #define RDI_CFG1_TIMESTAMP_STB_SEL 0 -#define CSID_RDI_CTRL(rdi) ((IS_LITE ? 0x208 : 0x308)\ +#define CSID_RDI_CTRL(rdi) ((csid_is_lite(csid) ? 0x208 : 0x308)\ + 0x100 * (rdi)) #define RDI_CTRL_HALT_CMD 0 #define HALT_CMD_HALT_AT_FRAME_BOUNDARY 0 #define HALT_CMD_RESUME_AT_FRAME_BOUNDARY 1 #define RDI_CTRL_HALT_MODE 2 -#define CSID_RDI_FRM_DROP_PATTERN(rdi) ((IS_LITE ? 0x20C : 0x30C)\ +#define CSID_RDI_FRM_DROP_PATTERN(rdi) ((csid_is_lite(csid) ? 0x20C : 0x30C)\ + 0x100 * (rdi)) -#define CSID_RDI_FRM_DROP_PERIOD(rdi) ((IS_LITE ? 0x210 : 0x310)\ +#define CSID_RDI_FRM_DROP_PERIOD(rdi) ((csid_is_lite(csid) ? 0x210 : 0x310)\ + 0x100 * (rdi)) -#define CSID_RDI_IRQ_SUBSAMPLE_PATTERN(rdi) ((IS_LITE ? 0x214 : 0x314)\ +#define CSID_RDI_IRQ_SUBSAMPLE_PATTERN(rdi) ((csid_is_lite(csid) ? 0x214 : 0x314)\ + 0x100 * (rdi)) -#define CSID_RDI_IRQ_SUBSAMPLE_PERIOD(rdi) ((IS_LITE ? 0x218 : 0x318)\ +#define CSID_RDI_IRQ_SUBSAMPLE_PERIOD(rdi) ((csid_is_lite(csid) ? 0x218 : 0x318)\ + 0x100 * (rdi)) -#define CSID_RDI_RPP_PIX_DROP_PATTERN(rdi) ((IS_LITE ? 0x224 : 0x324)\ +#define CSID_RDI_RPP_PIX_DROP_PATTERN(rdi) ((csid_is_lite(csid) ? 0x224 : 0x324)\ + 0x100 * (rdi)) -#define CSID_RDI_RPP_PIX_DROP_PERIOD(rdi) ((IS_LITE ? 0x228 : 0x328)\ +#define CSID_RDI_RPP_PIX_DROP_PERIOD(rdi) ((csid_is_lite(csid) ? 0x228 : 0x328)\ + 0x100 * (rdi)) -#define CSID_RDI_RPP_LINE_DROP_PATTERN(rdi) ((IS_LITE ? 0x22C : 0x32C)\ +#define CSID_RDI_RPP_LINE_DROP_PATTERN(rdi) ((csid_is_lite(csid) ? 0x22C : 0x32C)\ + 0x100 * (rdi)) -#define CSID_RDI_RPP_LINE_DROP_PERIOD(rdi) ((IS_LITE ? 0x230 : 0x330)\ +#define CSID_RDI_RPP_LINE_DROP_PERIOD(rdi) ((csid_is_lite(csid) ? 0x230 : 0x330)\ + 0x100 * (rdi)) #define CSID_TPG_CTRL 0x600 diff --git a/drivers/media/platform/qcom/camss/camss-csid.c b/drivers/media/platform/qcom/camss/camss-csid.c index 95873f988f7e2..d393618ed54cb 100644 --- a/drivers/media/platform/qcom/camss/camss-csid.c +++ b/drivers/media/platform/qcom/camss/camss-csid.c @@ -897,3 +897,8 @@ void msm_csid_unregister_entity(struct csid_device *csid) media_entity_cleanup(&csid->subdev.entity); v4l2_ctrl_handler_free(&csid->ctrls); } + +inline bool csid_is_lite(struct csid_device *csid) +{ + return csid->camss->res->csid_res[csid->id].is_lite; +} diff --git a/drivers/media/platform/qcom/camss/camss-csid.h b/drivers/media/platform/qcom/camss/camss-csid.h index 30d94eb2eb041..fddccb69da13a 100644 --- a/drivers/media/platform/qcom/camss/camss-csid.h +++ b/drivers/media/platform/qcom/camss/camss-csid.h @@ -215,5 +215,12 @@ extern const struct csid_hw_ops csid_ops_4_1; extern const struct csid_hw_ops csid_ops_4_7; extern const struct csid_hw_ops csid_ops_gen2; +/* + * csid_is_lite - Check if CSID is CSID lite. + * @csid: CSID Device + * + * Return whether CSID is CSID lite + */ +bool csid_is_lite(struct csid_device *csid); #endif /* QC_MSM_CAMSS_CSID_H */ diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c index f5226eb8bf4fc..51ad12f1d9d7d 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -638,6 +638,7 @@ static const struct camss_subdev_resources csid_res_845[] = { { 384000000 } }, .reg = { "csid2" }, .interrupt = { "csid2" }, + .is_lite = true, .ops = &csid_ops_gen2 } }; @@ -812,6 +813,7 @@ static const struct camss_subdev_resources csid_res_8250[] = { { 0 } }, .reg = { "csid2" }, .interrupt = { "csid2" }, + .is_lite = true, .ops = &csid_ops_gen2 }, /* CSID3 */ @@ -824,6 +826,7 @@ static const struct camss_subdev_resources csid_res_8250[] = { { 0 } }, .reg = { "csid3" }, .interrupt = { "csid3" }, + .is_lite = true, .ops = &csid_ops_gen2 } };