Skip to content

Commit d5d73e6

Browse files
Niklas Söderlundmorimoto
authored andcommitted
media: rcar-csi2: Prepare for C-PHY support
Gen4 will support both D-PHY and C-PHY, while Gen3 only supports D-PHY. Add two flags to the device information structure to be able to record what each SoC supports. Extend the device node parsing to accept both CSI_2 D-PHY and C-PHY buses, while at the same time taking the SoC support into account. Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> [Sakari Ailus: Line wrap.] Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> (cherry picked from commit e103484) Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
1 parent 072cb92 commit d5d73e6

File tree

1 file changed

+57
-10
lines changed

1 file changed

+57
-10
lines changed

drivers/media/platform/renesas/rcar-vin/rcar-csi2.c

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,8 @@ struct rcar_csi2_info {
490490
unsigned int num_channels;
491491
bool clear_ulps;
492492
bool use_isp;
493+
bool support_dphy;
494+
bool support_cphy;
493495
};
494496

495497
struct rcar_csi2 {
@@ -511,6 +513,7 @@ struct rcar_csi2 {
511513
struct v4l2_mbus_framefmt mf;
512514
int stream_count;
513515

516+
bool cphy;
514517
unsigned short lanes;
515518
unsigned char lane_swap[4];
516519
};
@@ -665,7 +668,16 @@ static int rcsi2_get_active_lanes(struct rcar_csi2 *priv,
665668
return ret;
666669
}
667670

668-
if (mbus_config.type != V4L2_MBUS_CSI2_DPHY) {
671+
switch (mbus_config.type) {
672+
case V4L2_MBUS_CSI2_CPHY:
673+
if (!priv->cphy)
674+
return -EINVAL;
675+
break;
676+
case V4L2_MBUS_CSI2_DPHY:
677+
if (priv->cphy)
678+
return -EINVAL;
679+
break;
680+
default:
669681
dev_err(priv->dev, "Unsupported media bus type %u\n",
670682
mbus_config.type);
671683
return -EINVAL;
@@ -1025,15 +1037,41 @@ static int rcsi2_parse_v4l2(struct rcar_csi2 *priv,
10251037
if (vep->base.port || vep->base.id)
10261038
return -ENOTCONN;
10271039

1028-
if (vep->bus_type != V4L2_MBUS_CSI2_DPHY) {
1029-
dev_err(priv->dev, "Unsupported bus: %u\n", vep->bus_type);
1030-
return -EINVAL;
1031-
}
1032-
10331040
priv->lanes = vep->bus.mipi_csi2.num_data_lanes;
1034-
if (priv->lanes != 1 && priv->lanes != 2 && priv->lanes != 4) {
1035-
dev_err(priv->dev, "Unsupported number of data-lanes: %u\n",
1036-
priv->lanes);
1041+
1042+
switch (vep->bus_type) {
1043+
case V4L2_MBUS_CSI2_DPHY:
1044+
if (!priv->info->support_dphy) {
1045+
dev_err(priv->dev, "D-PHY not supported\n");
1046+
return -EINVAL;
1047+
}
1048+
1049+
if (priv->lanes != 1 && priv->lanes != 2 && priv->lanes != 4) {
1050+
dev_err(priv->dev,
1051+
"Unsupported number of data-lanes for D-PHY: %u\n",
1052+
priv->lanes);
1053+
return -EINVAL;
1054+
}
1055+
1056+
priv->cphy = false;
1057+
break;
1058+
case V4L2_MBUS_CSI2_CPHY:
1059+
if (!priv->info->support_cphy) {
1060+
dev_err(priv->dev, "C-PHY not supported\n");
1061+
return -EINVAL;
1062+
}
1063+
1064+
if (priv->lanes != 3) {
1065+
dev_err(priv->dev,
1066+
"Unsupported number of data-lanes for C-PHY: %u\n",
1067+
priv->lanes);
1068+
return -EINVAL;
1069+
}
1070+
1071+
priv->cphy = true;
1072+
break;
1073+
default:
1074+
dev_err(priv->dev, "Unsupported bus: %u\n", vep->bus_type);
10371075
return -EINVAL;
10381076
}
10391077

@@ -1057,7 +1095,7 @@ static int rcsi2_parse_dt(struct rcar_csi2 *priv)
10571095
struct fwnode_handle *fwnode;
10581096
struct fwnode_handle *ep;
10591097
struct v4l2_fwnode_endpoint v4l2_ep = {
1060-
.bus_type = V4L2_MBUS_CSI2_DPHY
1098+
.bus_type = V4L2_MBUS_UNKNOWN,
10611099
};
10621100
int ret;
10631101

@@ -1378,6 +1416,7 @@ static const struct rcar_csi2_info rcar_csi2_info_r8a7795 = {
13781416
.csi0clkfreqrange = 0x20,
13791417
.num_channels = 4,
13801418
.clear_ulps = true,
1419+
.support_dphy = true,
13811420
};
13821421

13831422
static const struct rcar_csi2_info rcar_csi2_info_r8a7795es2 = {
@@ -1388,20 +1427,23 @@ static const struct rcar_csi2_info rcar_csi2_info_r8a7795es2 = {
13881427
.csi0clkfreqrange = 0x20,
13891428
.num_channels = 4,
13901429
.clear_ulps = true,
1430+
.support_dphy = true,
13911431
};
13921432

13931433
static const struct rcar_csi2_info rcar_csi2_info_r8a7796 = {
13941434
.start_receiver = rcsi2_start_receiver_gen3,
13951435
.enter_standby = rcsi2_enter_standby_gen3,
13961436
.hsfreqrange = hsfreqrange_m3w,
13971437
.num_channels = 4,
1438+
.support_dphy = true,
13981439
};
13991440

14001441
static const struct rcar_csi2_info rcar_csi2_info_r8a77961 = {
14011442
.start_receiver = rcsi2_start_receiver_gen3,
14021443
.enter_standby = rcsi2_enter_standby_gen3,
14031444
.hsfreqrange = hsfreqrange_m3w,
14041445
.num_channels = 4,
1446+
.support_dphy = true,
14051447
};
14061448

14071449
static const struct rcar_csi2_info rcar_csi2_info_r8a77965 = {
@@ -1412,6 +1454,7 @@ static const struct rcar_csi2_info rcar_csi2_info_r8a77965 = {
14121454
.csi0clkfreqrange = 0x20,
14131455
.num_channels = 4,
14141456
.clear_ulps = true,
1457+
.support_dphy = true,
14151458
};
14161459

14171460
static const struct rcar_csi2_info rcar_csi2_info_r8a77970 = {
@@ -1420,6 +1463,7 @@ static const struct rcar_csi2_info rcar_csi2_info_r8a77970 = {
14201463
.start_receiver = rcsi2_start_receiver_gen3,
14211464
.enter_standby = rcsi2_enter_standby_gen3,
14221465
.num_channels = 4,
1466+
.support_dphy = true,
14231467
};
14241468

14251469
static const struct rcar_csi2_info rcar_csi2_info_r8a77980 = {
@@ -1429,6 +1473,7 @@ static const struct rcar_csi2_info rcar_csi2_info_r8a77980 = {
14291473
.hsfreqrange = hsfreqrange_h3_v3h_m3n,
14301474
.csi0clkfreqrange = 0x20,
14311475
.clear_ulps = true,
1476+
.support_dphy = true,
14321477
};
14331478

14341479
static const struct rcar_csi2_info rcar_csi2_info_r8a77990 = {
@@ -1437,6 +1482,7 @@ static const struct rcar_csi2_info rcar_csi2_info_r8a77990 = {
14371482
.start_receiver = rcsi2_start_receiver_gen3,
14381483
.enter_standby = rcsi2_enter_standby_gen3,
14391484
.num_channels = 2,
1485+
.support_dphy = true,
14401486
};
14411487

14421488
static const struct rcar_csi2_info rcar_csi2_info_r8a779a0 = {
@@ -1447,6 +1493,7 @@ static const struct rcar_csi2_info rcar_csi2_info_r8a779a0 = {
14471493
.csi0clkfreqrange = 0x20,
14481494
.clear_ulps = true,
14491495
.use_isp = true,
1496+
.support_dphy = true,
14501497
};
14511498

14521499
static const struct of_device_id rcar_csi2_of_table[] = {

0 commit comments

Comments
 (0)