Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2461765rwb; Sat, 24 Sep 2022 08:43:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6XqfDc35UIIg7DXJ0j6tvRLe9zEfguZTa+2QC7YF8/eEf6xkFtFlp1XCLb0u4jKtlFq8/9 X-Received: by 2002:a63:7984:0:b0:439:57e4:97a2 with SMTP id u126-20020a637984000000b0043957e497a2mr12645635pgc.191.1664034239253; Sat, 24 Sep 2022 08:43:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664034239; cv=none; d=google.com; s=arc-20160816; b=DKqna4qQyQL70pICg168wt56yX+fMybLRksUYQzFTNo2dTQoj8yB4wOecBAakMXYo3 FLzOQApB+HBBwgSRDN9VO42nXtTtMlLdygeHwFUkRcKx/3TVg1sEbui+nMENtMSSjcRe IXxP5yDjqeaMbqq9A2BNwz6ELNuvwpSjlzunb33QOnxWtPWxZpblRWc5cZXCwlN1XxJr I42AHor7/2zba+2LHOXkbtIy4WqnspyjOeE1HOZvddx3p0hNZpTe8X5ihD3pQgkAKRA1 fJbCfE9rFkdWbd7nGzUg0Z5d2nuDDRLJV+A4BgMQ5Qxd5LouH/asmuKCq5H74RGFOSke IEOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4GiWn6/vCDTKRkhhkK6F1hPUXTYYUMDoGhjDkVc/pSI=; b=SYeeoe4qWjqTL1VOEuUqkbnNtCYB+KjCSWA65mdmb1NZn+15SAajfNKTTsxi6U8oHi eCMi5regWQYvvOL6ZC9yF1jZ1aAcavcMdD1Gvymf1VbpqgKy7Smrk17usUHYHOUkXaJi enhGef7fVFH298MOWe5Y/JaGymPkYpLiKM/Brckp4l1HFND9kSLVdi8pfC0sTBxCdOTu VomLep3XbP7n3FNZMAm0FN4bAMp9gr5Fz6MqV+AsyWTF2BZ+oBvopsltz29X1vHjPJWv +0nG1yT+HRSWR3zmMTiWdLn7XaVUHFwPr6wc1Xp7Ap89vAb+ZwtOmls0FxfHg5eOxnRv 29xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=N41dsPcg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d9-20020a655889000000b0043a6caebacesi12468765pgu.52.2022.09.24.08.43.47; Sat, 24 Sep 2022 08:43:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=N41dsPcg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234043AbiIXPd4 (ORCPT + 99 others); Sat, 24 Sep 2022 11:33:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233941AbiIXPdf (ORCPT ); Sat, 24 Sep 2022 11:33:35 -0400 Received: from relay10.mail.gandi.net (relay10.mail.gandi.net [IPv6:2001:4b98:dc4:8::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13BFBB56E6; Sat, 24 Sep 2022 08:33:27 -0700 (PDT) Received: (Authenticated sender: paul.kocialkowski@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 4F4B5240009; Sat, 24 Sep 2022 15:33:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1664033606; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4GiWn6/vCDTKRkhhkK6F1hPUXTYYUMDoGhjDkVc/pSI=; b=N41dsPcgPv6eS7c9qet350sLD1PyGUDYPGanLDXUBNVgEz2NmTwPXJRCkxwRdy9ooWWATz Uwg2GBzW0oQW7BZ6kd+KNCQrNa4t8RMis+JUeRT1bjamonGCuVDKl8Ten4fBrnNF2Gm3+o TSJxBKxRpHbDUABwpoNcTJ0Yw57PRfC1P801TXohg0tlYE4exlOcNSnO+XKgn9vgQ3zles 1A1uGoRJsyKSowFfkwiokpD2KODf55IfWp/usJonovV4zwwsND+QXjerhg+UUdl6xZ1p/4 CEtgbhvYWu6wkSqE6rFAK/6mdm9h5Y7J6bRB3m0V42VxSFtwQd7yJ5qUKnq1Bw== From: Paul Kocialkowski To: linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Hans Verkuil , Laurent Pinchart , Maxime Ripard , Thomas Petazzoni Subject: [PATCH v7 5/6] media: sun6i-csi: Detect the availability of the ISP Date: Sat, 24 Sep 2022 17:33:03 +0200 Message-Id: <20220924153304.77598-6-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220924153304.77598-1-paul.kocialkowski@bootlin.com> References: <20220924153304.77598-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS 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 Add a helper to detect whether the ISP is available and connected and store the indication in the driver-specific device structure. Signed-off-by: Paul Kocialkowski --- .../platform/sunxi/sun6i-csi/sun6i_csi.c | 34 +++++++++++++++++++ .../platform/sunxi/sun6i-csi/sun6i_csi.h | 3 ++ 2 files changed, 37 insertions(+) diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c index 00521f966cee..046fc9d018eb 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c @@ -24,6 +24,36 @@ #include "sun6i_csi_capture.h" #include "sun6i_csi_reg.h" +/* ISP */ + +static int sun6i_csi_isp_detect(struct sun6i_csi_device *csi_dev) +{ + struct device *dev = csi_dev->dev; + struct fwnode_handle *handle; + + /* + * ISP is not available if not connected via fwnode graph. + * This will also check that the remote parent node is available. + */ + handle = fwnode_graph_get_endpoint_by_id(dev_fwnode(dev), + SUN6I_CSI_PORT_ISP, 0, + FWNODE_GRAPH_ENDPOINT_NEXT); + if (!handle) + return 0; + + fwnode_handle_put(handle); + + if (!IS_ENABLED(CONFIG_VIDEO_SUN6I_ISP)) { + dev_warn(dev, + "ISP link is detected but not enabled in kernel config!"); + return 0; + } + + csi_dev->isp_available = true; + + return 0; +} + /* Media */ static const struct media_device_ops sun6i_csi_media_ops = { @@ -290,6 +320,10 @@ static int sun6i_csi_probe(struct platform_device *platform_dev) if (ret) return ret; + ret = sun6i_csi_isp_detect(csi_dev); + if (ret) + goto error_resources; + ret = sun6i_csi_v4l2_setup(csi_dev); if (ret) goto error_resources; diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h index e611bdd6e9b2..8e232cd91ebe 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h @@ -21,6 +21,7 @@ enum sun6i_csi_port { SUN6I_CSI_PORT_PARALLEL = 0, SUN6I_CSI_PORT_MIPI_CSI2 = 1, + SUN6I_CSI_PORT_ISP = 2, }; struct sun6i_csi_buffer { @@ -44,6 +45,8 @@ struct sun6i_csi_device { struct clk *clock_mod; struct clk *clock_ram; struct reset_control *reset; + + bool isp_available; }; struct sun6i_csi_variant { -- 2.37.3