Skip to content

Commit a91d06f

Browse files
Pratyush YadavHans Verkuil
authored andcommitted
media: cadence: csi2rx: Configure DPHY using link freq
Some platforms like TI's J721E can have the CSI2RX paired with an external DPHY. Use the generic PHY framework to configure the DPHY with the correct link frequency. Signed-off-by: Pratyush Yadav <p.yadav@ti.com> Tested-by: Julien Massot <julien.massot@collabora.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Reviewed-by: Maxime Ripard <mripard@kernel.org> Co-developed-by: Jai Luthra <j-luthra@ti.com> Signed-off-by: Jai Luthra <j-luthra@ti.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
1 parent dbca7b3 commit a91d06f

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

drivers/media/platform/cadence/cdns-csi2rx.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,32 @@ static void csi2rx_reset(struct csi2rx_priv *csi2rx)
145145
static int csi2rx_configure_ext_dphy(struct csi2rx_priv *csi2rx)
146146
{
147147
union phy_configure_opts opts = { };
148+
struct phy_configure_opts_mipi_dphy *cfg = &opts.mipi_dphy;
149+
struct v4l2_subdev_format sd_fmt = {
150+
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
151+
.pad = CSI2RX_PAD_SINK,
152+
};
153+
const struct csi2rx_fmt *fmt;
154+
s64 link_freq;
148155
int ret;
149156

157+
ret = v4l2_subdev_call_state_active(&csi2rx->subdev, pad, get_fmt,
158+
&sd_fmt);
159+
if (ret < 0)
160+
return ret;
161+
162+
fmt = csi2rx_get_fmt_by_code(sd_fmt.format.code);
163+
164+
link_freq = v4l2_get_link_freq(csi2rx->source_subdev->ctrl_handler,
165+
fmt->bpp, 2 * csi2rx->num_lanes);
166+
if (link_freq < 0)
167+
return link_freq;
168+
169+
ret = phy_mipi_dphy_get_default_config_for_hsclk(link_freq,
170+
csi2rx->num_lanes, cfg);
171+
if (ret)
172+
return ret;
173+
150174
ret = phy_power_on(csi2rx->dphy);
151175
if (ret)
152176
return ret;

0 commit comments

Comments
 (0)