From nobody Tue Apr 7 08:13:03 2026 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 269E42798ED for ; Mon, 16 Mar 2026 01:02:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773622938; cv=none; b=iXPEbNRdD+jzoyNg1IzFNUu5+AY/KB3vZe0XJnZjEkstzox5lXKXjsdU9u/Jpz3gNesnMusxU2/mOQ5lMjBR/5sPCdR1b6tS1TaR9dbbGZfSJqplrxxxfl/caf5ZbhNirT5/UdXAY4X0dTXeeOjBFll+2+sBrVmxnPhHkCn830A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773622938; c=relaxed/simple; bh=oZ9movgz3y3a+s25qO8ApIoTiD09HxKxeoCZJZcUMLs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XYCOOzUERUJLAm7/8jEIPkXXQ75VG3B3hcMlMw8ukhrfO4HCiw+uPSXtHAsKZ8A/0FtqOjDoyI0Abp03DTiqZvVdN7g2sYGnOP5k08tB3gpaS/VebxHCSilcYwtYlRnUS/7xfQb4UqYl1xJKbgos+ZIL8hgQEUiJ/JzxmtO784Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=svt2RsuU; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="svt2RsuU" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4852afd42ceso35106045e9.2 for ; Sun, 15 Mar 2026 18:02:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1773622931; x=1774227731; 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=xxr/EzxAKZpEbyX4qAuriPKBOfBak1fbxwW1huFfCcA=; b=svt2RsuU20wV/ANtFNHQBeM4DdRgVZJ5NfvDZJO7Htc83LzZLHoHA0U8gVIdFZPkPQ PSCewi3c4pt5ZTq7OKcsO29KoGLyf2SKxPdb+Cq+1zTJy3v4c/mH8ddysHV2x7ceT5vo CebtL5VRsrchd8cfZvwZxnw10oAdj10AMo13vduKugIpR6sk4mnCrSibMz9W4jKiGFSt aZmhg9ApYji3WrUi0qFA1WrtrwMjMU27CXm9ClHfEBJ33ae72Z5NFq1HP5rJYEalIWw1 YPm2Z5GTBPb+nAf3hHIWZWKu5+V+XiVbd2XZT7pFcReHfvfUurVpjzolOkkrKzYxwiAf sNSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773622931; x=1774227731; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=xxr/EzxAKZpEbyX4qAuriPKBOfBak1fbxwW1huFfCcA=; b=KSvD+ATn6nEiuh8vse2QewYEcGl+oyeMV4LD7ZM7Hd8agOJO/baWYin6v/3c4fNAwU l5MCJeMSA0wOqsaWtcpGjTIi8CfzK7zR2msu4i+zE81hFKabse1mZOxs4A7vaoLNbZ6m /1mJOcQn5qQDwlLjg0wiajj0g/SyfkFW8edqCfWfxnKXkGxZ/7FAcF3CT7pXRQu6Zkgt XrpKcOoEk7PQ6k4z7ws0GYa4EeKroyIceyLLu+MErsKkagORboBGfqyq/BrgsZ9K4aPA JOHUK3HNAQ9Arky+gvqNvS3y3uHP3N187TWFbrgSSEgJYiouMzp+si2EdY52dn4he4BD MSeg== X-Forwarded-Encrypted: i=1; AJvYcCW40JLrCwal0JNq/EhpzrPmhjET63d4CFe7g9Q5OZ8mgS8USdQqECQ5iSNYDAVqej3gk/Qo0PiMBpjpS3U=@vger.kernel.org X-Gm-Message-State: AOJu0YxEHUAFfy6WFaA+1ifxh97elb1dS6p1kq4InJU4VUsItxdvJ5wY 9qyZb+guP7UqMbgAGb5EpXTK0sLb1UWp2cPO0yPKyULgnYb7IW1yh1O/NrLPUZYEJ8g= X-Gm-Gg: ATEYQzz24ekOrKgGOwE9UNzIz0XqVrnsQMMljUUNxKL6MTNGBEWZYQGoE6cdXTjkWqI Cqb2s4wmtYu9NbuEZlc8wyJ9cWjaHA6ronKBeBf49oiUXn2x/mHcNXAv4qSVc92i86FjIJjVZVD JlswrZyxqQrFZpNPTV9+CMOJazbm6NnVcSkxxS0UXnK/0vQCSA1WNlp22fMuf3X80dCIM8PQCuW sGCpZ+gReCZUrhBEOsJQjCCPUII+2iOZCcd7WH7eq4Inwgp2ylAeUJvmamVzw8jgq+AlR3kJd8b zrsnMyx3DSS004EbUoO4kHVykw6xL/lHUS6V1CEr1QuUqJIRE3KNJT3mFBNbyT2jTb56T0cIr9g +3TgHw+yEPd+GS7HscUrAsRg765/knhAguvVXPZ5aaVTLe8oNcGKYi3Jf3sqGRZvQtczParmYlc nFAmO1rq4/RRJjhB5EaCseRtUNStku/ECqesY= X-Received: by 2002:a05:600c:4fc6:b0:479:1b0f:dfff with SMTP id 5b1f17b1804b1-485566cfccfmr177824275e9.10.1773622931161; Sun, 15 Mar 2026 18:02:11 -0700 (PDT) Received: from [192.168.0.35] ([109.76.190.215]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439fe228986sm34729700f8f.35.2026.03.15.18.02.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Mar 2026 18:02:09 -0700 (PDT) From: Bryan O'Donoghue Date: Mon, 16 Mar 2026 01:02:06 +0000 Subject: [PATCH v10 6/7] media: qcom: camss: Add support for PHY API devices Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260316-b4-linux-next-25-03-13-dtsi-x1e80100-camss-v10-6-fdfe984fe941@linaro.org> References: <20260316-b4-linux-next-25-03-13-dtsi-x1e80100-camss-v10-0-fdfe984fe941@linaro.org> In-Reply-To: <20260316-b4-linux-next-25-03-13-dtsi-x1e80100-camss-v10-0-fdfe984fe941@linaro.org> To: Bjorn Andersson , Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robert Foss , Todor Tomov , Mauro Carvalho Chehab , Konrad Dybcio , Vladimir Zapolskiy , Bryan O'Donoghue Cc: linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, Bryan O'Donoghue , Krzysztof Kozlowski , Christopher Obbard X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=15878; i=bryan.odonoghue@linaro.org; h=from:subject:message-id; bh=oZ9movgz3y3a+s25qO8ApIoTiD09HxKxeoCZJZcUMLs=; b=owEBbQKS/ZANAwAKASJxO7Ohjcg6AcsmYgBpt1aNERxdqR6/TNlfe8OHkq1d7dI66v+tpwuLS Eiae25LVLCJAjMEAAEKAB0WIQTmk/sqq6Nt4Rerb7QicTuzoY3IOgUCabdWjQAKCRAicTuzoY3I Ohf3D/wOwTLCZrq53WPbbd6riC7SihVNUFi+NvN/Yj1WZYxU1dC189Llj3yjVcbo37G0S08juVo hxkj5o2zX7fgIgvBhPThmzG62b6/GtNzUD35XKotmSxd4V2c35bsYWV52lsejtODtGQMf6/UoRP 0tHf0w9ojVjGTDx6EV1ocx5AQvZ4PnYRQ0zY7zum22Wv0/JrkLvq3N84nLTX8zqKnh+jyIlB5tH b1pV0aUurL3vMiggluhgL44Ot6+vUa+XQ2Rh8q62jbAlnrVfizYRQAhUKikS0UFRVJHAWPNHBF0 dTC80OTXps/ZzpvpOb1GwBEfND68qO2NNE9EZOvcWL+ET+lGXSKjxjYUCDeUD9urx3nU3GWrQDe hxlH3mCTcHXwJcLUZu0hJpPo86w+6+mwtPNy4QBNmO2Iio89lFWpb1Uzq5nW5IfXix48+INPVQC i8cXV8H94xHorot5z2WJs6x70ABT/bZm2G6oxfWgIpl/Hd+kdF1IoOXMIWw1k6/4q26iRURJDbB +WgoymDrLhcH5zPSNfsyCt9DI6J7YT0Y/O4W77rKq772SFV8KAQXqzku+57pofoMw0m0CFhsdSk 0L8aF4jlCLoNxfUG2t4C+2RK83Odq5ubLK014NdryLHs0VRmV8RkSyRgZofc8AUmBdI/3XY0OTy QfmxI0vJvBXtZtQ== X-Developer-Key: i=bryan.odonoghue@linaro.org; a=openpgp; fpr=E693FB2AABA36DE117AB6FB422713BB3A18DC83A Add the ability to use a PHY pointer which interacts with the standard PHY API. In the first instance the code will try to use the new PHY interface. If no PHYs are present in the DT then the legacy method will be attempted. Reviewed-by: Christopher Obbard Tested-by: Christopher Obbard Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/Kconfig | 1 + drivers/media/platform/qcom/camss/camss-csiphy.c | 185 +++++++++++++++++++= ++-- drivers/media/platform/qcom/camss/camss-csiphy.h | 7 + drivers/media/platform/qcom/camss/camss.c | 72 +++++++-- 4 files changed, 235 insertions(+), 30 deletions(-) diff --git a/drivers/media/platform/qcom/camss/Kconfig b/drivers/media/plat= form/qcom/camss/Kconfig index 4eda48cb1adf0..1edc5e5a1829e 100644 --- a/drivers/media/platform/qcom/camss/Kconfig +++ b/drivers/media/platform/qcom/camss/Kconfig @@ -7,3 +7,4 @@ config VIDEO_QCOM_CAMSS select VIDEO_V4L2_SUBDEV_API select VIDEOBUF2_DMA_SG select V4L2_FWNODE + select PHY_QCOM_MIPI_CSI2 diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/med= ia/platform/qcom/camss/camss-csiphy.c index 62623393f4144..b8bfbf2fef8fa 100644 --- a/drivers/media/platform/qcom/camss/camss-csiphy.c +++ b/drivers/media/platform/qcom/camss/camss-csiphy.c @@ -7,12 +7,14 @@ * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved. * Copyright (C) 2016-2018 Linaro Ltd. */ +#include #include #include #include #include #include #include +#include #include #include #include @@ -131,10 +133,10 @@ static u8 csiphy_get_bpp(const struct csiphy_format_i= nfo *formats, } =20 /* - * csiphy_set_clock_rates - Calculate and set clock rates on CSIPHY module + * csiphy_set_clock_rates_legacy - Calculate and set clock rates on CSIPHY= module * @csiphy: CSIPHY device */ -static int csiphy_set_clock_rates(struct csiphy_device *csiphy) +static int csiphy_set_clock_rates_legacy(struct csiphy_device *csiphy) { struct device *dev =3D csiphy->camss->dev; s64 link_freq; @@ -200,7 +202,7 @@ static int csiphy_set_clock_rates(struct csiphy_device = *csiphy) * * Return 0 on success or a negative error code otherwise */ -static int csiphy_set_power(struct v4l2_subdev *sd, int on) +static int csiphy_set_power_legacy(struct v4l2_subdev *sd, int on) { struct csiphy_device *csiphy =3D v4l2_get_subdevdata(sd); struct device *dev =3D csiphy->camss->dev; @@ -219,7 +221,7 @@ static int csiphy_set_power(struct v4l2_subdev *sd, int= on) return ret; } =20 - ret =3D csiphy_set_clock_rates(csiphy); + ret =3D csiphy_set_clock_rates_legacy(csiphy); if (ret < 0) { regulator_bulk_disable(csiphy->num_supplies, csiphy->supplies); @@ -254,7 +256,7 @@ static int csiphy_set_power(struct v4l2_subdev *sd, int= on) } =20 /* - * csiphy_stream_on - Enable streaming on CSIPHY module + * csiphy_stream_on_legacy - Enable streaming on CSIPHY module * @csiphy: CSIPHY device * * Helper function to enable streaming on CSIPHY module. @@ -262,7 +264,7 @@ static int csiphy_set_power(struct v4l2_subdev *sd, int= on) * * Return 0 on success or a negative error code otherwise */ -static int csiphy_stream_on(struct csiphy_device *csiphy) +static int csiphy_stream_on_legacy(struct csiphy_device *csiphy) { struct csiphy_config *cfg =3D &csiphy->cfg; s64 link_freq; @@ -306,11 +308,86 @@ static int csiphy_stream_on(struct csiphy_device *csi= phy) * * Helper function to disable streaming on CSIPHY module */ -static void csiphy_stream_off(struct csiphy_device *csiphy) +static void csiphy_stream_off_legacy(struct csiphy_device *csiphy) { csiphy->res->hw_ops->lanes_disable(csiphy, &csiphy->cfg); } =20 +/* + * csiphy_stream_on - Enable streaming on CSIPHY module + * @csiphy: CSIPHY device + * + * Helper function to enable streaming on CSIPHY module. + * Main configuration of CSIPHY module is also done here. + * + * Return 0 on success or a negative error code otherwise + */ +static int csiphy_stream_on(struct csiphy_device *csiphy) +{ + u8 bpp =3D csiphy_get_bpp(csiphy->res->formats->formats, csiphy->res->for= mats->nformats, + csiphy->fmt[MSM_CSIPHY_PAD_SINK].code); + u8 num_lanes =3D csiphy->cfg.csi2->lane_cfg.num_data; + struct phy_configure_opts_mipi_dphy *dphy_cfg; + union phy_configure_opts dphy_opts =3D { 0 }; + struct device *dev =3D csiphy->camss->dev; + s64 link_freq; + int ret; + + dphy_cfg =3D &dphy_opts.mipi_dphy; + + link_freq =3D camss_get_link_freq(&csiphy->subdev.entity, bpp, num_lanes); + + if (link_freq < 0) { + dev_err(dev, + "Cannot get CSI2 transmitter's link frequency\n"); + return -EINVAL; + } + + phy_mipi_dphy_get_default_config_for_hsclk(link_freq, num_lanes, dphy_cfg= ); + + phy_set_mode(csiphy->phy, PHY_MODE_MIPI_DPHY); + ret =3D phy_configure(csiphy->phy, &dphy_opts); + if (ret) { + dev_err(dev, "failed to configure MIPI D-PHY\n"); + goto error; + } + + return phy_power_on(csiphy->phy); + +error: + return ret; +} + +/* + * csiphy_stream_off - Disable streaming on CSIPHY module + * @csiphy: CSIPHY device + * + * Helper function to disable streaming on CSIPHY module + */ +static void csiphy_stream_off(struct csiphy_device *csiphy) +{ + phy_power_off(csiphy->phy); +} + +/* + * csiphy_set_stream - Enable/disable streaming on CSIPHY module + * @sd: CSIPHY V4L2 subdevice + * @enable: Requested streaming state + * + * Return 0 on success or a negative error code otherwise + */ +static int csiphy_set_stream_legacy(struct v4l2_subdev *sd, int enable) +{ + struct csiphy_device *csiphy =3D v4l2_get_subdevdata(sd); + int ret =3D 0; + + if (enable) + ret =3D csiphy_stream_on_legacy(csiphy); + else + csiphy_stream_off_legacy(csiphy); + + return ret; +} =20 /* * csiphy_set_stream - Enable/disable streaming on CSIPHY module @@ -568,16 +645,16 @@ static bool csiphy_match_clock_name(const char *clock= _name, const char *format, } =20 /* - * msm_csiphy_subdev_init - Initialize CSIPHY device structure and resourc= es + * msm_csiphy_subdev_init_legacy - Initialize CSIPHY device structure and = resources * @csiphy: CSIPHY device * @res: CSIPHY module resources table * @id: CSIPHY module id * * Return 0 on success or a negative error code otherwise */ -int msm_csiphy_subdev_init(struct camss *camss, - struct csiphy_device *csiphy, - const struct camss_subdev_resources *res, u8 id) +int msm_csiphy_subdev_init_legacy(struct camss *camss, + struct csiphy_device *csiphy, + const struct camss_subdev_resources *res, u8 id) { struct device *dev =3D camss->dev; struct platform_device *pdev =3D to_platform_device(dev); @@ -705,6 +782,69 @@ int msm_csiphy_subdev_init(struct camss *camss, return ret; } =20 +/* + * msm_csiphy_subdev_init - Initialize CSIPHY device structure and resourc= es + * @csiphy: CSIPHY device + * @res: CSIPHY module resources table + * @id: CSIPHY module id + * + * Return 0 on success or a negative error code otherwise + */ +int msm_csiphy_subdev_init(struct camss *camss, + struct csiphy_device *csiphy, + const struct camss_subdev_resources *res, u8 id) +{ + struct device *dev =3D camss->dev; + struct of_phandle_args args; + u8 combo_mode; + int idx; + int ret; + + snprintf(csiphy->name, ARRAY_SIZE(csiphy->name), "csiphy%d", id); + + idx =3D of_property_match_string(dev->of_node, "phy-names", csiphy->name); + if (idx < 0) { + dev_err(dev, "%s not found\n", csiphy->name); + return idx; + } + + ret =3D of_parse_phandle_with_args(dev->of_node, "phys", "#phy-cells", id= x, &args); + if (ret < 0) { + dev_err(dev, "unable to parse phys args %s\n", csiphy->name); + return ret; + } + + if (!of_device_is_available(args.np)) + goto put_np; + + combo_mode =3D args.args[0]; + if (combo_mode !=3D PHY_TYPE_DPHY) { + dev_err(dev, "%s mode %d not supported\n", csiphy->name, combo_mode); + ret =3D -EOPNOTSUPP; + goto put_np; + } + + csiphy->phy =3D devm_phy_get(dev, csiphy->name); + if (IS_ERR(csiphy->phy)) { + ret =3D PTR_ERR(csiphy->phy); + goto put_np; + } + + csiphy->camss =3D camss; + csiphy->id =3D id; + csiphy->cfg.combo_mode =3D combo_mode; + csiphy->res =3D &res->csiphy; + + ret =3D phy_init(csiphy->phy); + if (ret) + dev_err(dev, "phy %s init fail %d\n", csiphy->name, ret); + +put_np: + of_node_put(args.np); + + return ret; +} + /* * csiphy_link_setup - Setup CSIPHY connections * @entity: Pointer to media entity structure @@ -739,8 +879,12 @@ static int csiphy_link_setup(struct media_entity *enti= ty, return 0; } =20 -static const struct v4l2_subdev_core_ops csiphy_core_ops =3D { - .s_power =3D csiphy_set_power, +static const struct v4l2_subdev_core_ops csiphy_core_ops_legacy =3D { + .s_power =3D csiphy_set_power_legacy, +}; + +static const struct v4l2_subdev_video_ops csiphy_video_ops_legacy =3D { + .s_stream =3D csiphy_set_stream_legacy, }; =20 static const struct v4l2_subdev_video_ops csiphy_video_ops =3D { @@ -754,8 +898,13 @@ static const struct v4l2_subdev_pad_ops csiphy_pad_ops= =3D { .set_fmt =3D csiphy_set_format, }; =20 +static const struct v4l2_subdev_ops csiphy_v4l2_ops_legacy =3D { + .core =3D &csiphy_core_ops_legacy, + .video =3D &csiphy_video_ops_legacy, + .pad =3D &csiphy_pad_ops, +}; + static const struct v4l2_subdev_ops csiphy_v4l2_ops =3D { - .core =3D &csiphy_core_ops, .video =3D &csiphy_video_ops, .pad =3D &csiphy_pad_ops, }; @@ -784,7 +933,11 @@ int msm_csiphy_register_entity(struct csiphy_device *c= siphy, struct device *dev =3D csiphy->camss->dev; int ret; =20 - v4l2_subdev_init(sd, &csiphy_v4l2_ops); + if (IS_ERR(csiphy->phy)) + v4l2_subdev_init(sd, &csiphy_v4l2_ops_legacy); + else + v4l2_subdev_init(sd, &csiphy_v4l2_ops); + sd->internal_ops =3D &csiphy_v4l2_internal_ops; sd->flags |=3D V4L2_SUBDEV_FL_HAS_DEVNODE; snprintf(sd->name, ARRAY_SIZE(sd->name), "%s%d", @@ -823,6 +976,8 @@ int msm_csiphy_register_entity(struct csiphy_device *cs= iphy, */ void msm_csiphy_unregister_entity(struct csiphy_device *csiphy) { + if (!IS_ERR(csiphy->phy)) + phy_exit(csiphy->phy); v4l2_device_unregister_subdev(&csiphy->subdev); media_entity_cleanup(&csiphy->subdev.entity); } diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.h b/drivers/med= ia/platform/qcom/camss/camss-csiphy.h index 2d5054819df7f..25b803c06e8bf 100644 --- a/drivers/media/platform/qcom/camss/camss-csiphy.h +++ b/drivers/media/platform/qcom/camss/camss-csiphy.h @@ -12,6 +12,7 @@ =20 #include #include +#include #include #include #include @@ -95,6 +96,7 @@ struct csiphy_device_regs { =20 struct csiphy_device { struct camss *camss; + struct phy *phy; u8 id; struct v4l2_subdev subdev; struct media_pad pads[MSM_CSIPHY_PADS_NUM]; @@ -102,6 +104,7 @@ struct csiphy_device { void __iomem *base_clk_mux; u32 irq; char irq_name[30]; + char name[16]; struct camss_clock *clock; bool *rate_set; int nclocks; @@ -116,6 +119,10 @@ struct csiphy_device { =20 struct camss_subdev_resources; =20 +int msm_csiphy_subdev_init_legacy(struct camss *camss, + struct csiphy_device *csiphy, + const struct camss_subdev_resources *res, u8 id); + int msm_csiphy_subdev_init(struct camss *camss, struct csiphy_device *csiphy, const struct camss_subdev_resources *res, u8 id); diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/plat= form/qcom/camss/camss.c index 5fb5ad87e1671..b1737b5d52160 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -4450,14 +4450,35 @@ static int camss_parse_endpoint_node(struct device = *dev, static int camss_parse_ports(struct camss *camss) { struct device *dev =3D camss->dev; + const struct camss_resources *res =3D camss->res; struct fwnode_handle *fwnode =3D dev_fwnode(dev), *ep; int ret; =20 fwnode_graph_for_each_endpoint(fwnode, ep) { struct camss_async_subdev *csd; + struct fwnode_handle *remote; + + if (!fwnode_device_is_available(ep)) + continue; + + if (res->legacy_phy) { + csd =3D v4l2_async_nf_add_fwnode_remote(&camss->notifier, ep, + typeof(*csd)); + } else { + /* + * For non-legacy PHY, the CSIPHY is a separate device. + * Register the remote endpoint (CSIPHY's endpoint) as + * the async subdev, not the remote port parent. + */ + remote =3D fwnode_graph_get_remote_endpoint(ep); + if (!remote) + continue; + + csd =3D v4l2_async_nf_add_fwnode(&camss->notifier, remote, + struct camss_async_subdev); + fwnode_handle_put(remote); + } =20 - csd =3D v4l2_async_nf_add_fwnode_remote(&camss->notifier, ep, - typeof(*csd)); if (IS_ERR(csd)) { ret =3D PTR_ERR(csd); goto err_cleanup; @@ -4489,15 +4510,26 @@ static int camss_init_subdevices(struct camss *cams= s) unsigned int i; int ret; =20 - for (i =3D 0; i < camss->res->csiphy_num; i++) { - ret =3D msm_csiphy_subdev_init(camss, &camss->csiphy[i], - &res->csiphy_res[i], - res->csiphy_res[i].csiphy.id); - if (ret < 0) { - dev_err(camss->dev, - "Failed to init csiphy%d sub-device: %d\n", - i, ret); - return ret; + if (!res->legacy_phy) { + for (i =3D 0; i < camss->res->csiphy_num; i++) { + ret =3D msm_csiphy_subdev_init(camss, &camss->csiphy[i], + &res->csiphy_res[i], + res->csiphy_res[i].csiphy.id); + if (ret < 0) + return ret; + } + } else { + for (i =3D 0; i < camss->res->csiphy_num; i++) { + ret =3D msm_csiphy_subdev_init_legacy(camss, &camss->csiphy[i], + &res->csiphy_res[i], + res->csiphy_res[i].csiphy.id); + if (ret < 0) { + dev_err(camss->dev, + "Failed to init csiphy%d sub-device: %d\n", + i, ret); + return ret; + } + camss->csiphy[i].phy =3D ERR_PTR(-ENODEV); } } =20 @@ -4574,6 +4606,9 @@ static int camss_link_entities(struct camss *camss) =20 for (i =3D 0; i < camss->res->csiphy_num; i++) { for (j =3D 0; j < camss->res->csid_num; j++) { + if (!camss->csiphy[i].phy) + continue; + ret =3D media_create_pad_link(&camss->csiphy[i].subdev.entity, MSM_CSIPHY_PAD_SRC, &camss->csid[j].subdev.entity, @@ -4683,6 +4718,9 @@ static int camss_register_entities(struct camss *cams= s) int ret; =20 for (i =3D 0; i < camss->res->csiphy_num; i++) { + if (!camss->csiphy[i].phy) + continue; + ret =3D msm_csiphy_register_entity(&camss->csiphy[i], &camss->v4l2_dev); if (ret < 0) { @@ -4738,8 +4776,10 @@ static int camss_register_entities(struct camss *cam= ss) =20 i =3D camss->res->csiphy_num; err_reg_csiphy: - for (i--; i >=3D 0; i--) - msm_csiphy_unregister_entity(&camss->csiphy[i]); + for (i--; i >=3D 0; i--) { + if (camss->csiphy[i].phy) + msm_csiphy_unregister_entity(&camss->csiphy[i]); + } =20 return ret; } @@ -4754,8 +4794,10 @@ static void camss_unregister_entities(struct camss *= camss) { unsigned int i; =20 - for (i =3D 0; i < camss->res->csiphy_num; i++) - msm_csiphy_unregister_entity(&camss->csiphy[i]); + for (i =3D 0; i < camss->res->csiphy_num; i++) { + if (camss->csiphy[i].phy) + msm_csiphy_unregister_entity(&camss->csiphy[i]); + } =20 for (i =3D 0; i < camss->res->csid_num; i++) msm_csid_unregister_entity(&camss->csid[i]); --=20 2.52.0