2022-05-23 07:59:18

by Luca Weiss

[permalink] [raw]
Subject: [RFC PATCH 00/14] CAMSS support for MSM8974

This RFC series adds support for CAMSS and CCI that are found on
msm8974, including the OV8865 found on the FP2.

The only reason it's marked RFC is that CAMSS doesn't behave properly on
this SoC without the last commit which is obviously not upstreamable.
Not sure if this should be a blocker for including most of the other
patches because other than that it seems to work fine and I can get a
picture from the camera sensor. When/if msm8974 gets IOMMU support I
hope this should be resolved and it works without this hack.

I think at least the CCI patches could get applied as they're not
dependent on the CAMSS hack?

Luca Weiss (5):
dt-bindings: i2c: qcom-cci: add QCOM MSM8974 compatible
ARM: dts: qcom: msm8974: add CCI bus
ARM: dts: qcom: msm8974: add CAMSS node
ARM: dts: qcom: msm8974-FP2: Add OV8865 rear camera
[DNM] media: camss: hacks for MSM8974

Matti Lehtimäki (9):
media: dt-bindings: media: camss: Add qcom,msm8974-camss binding
media: camss: Add CAMSS_8x74 camss version
media: camss: vfe: Add support for 8x74
media: camss: video: Add support for 8x74
media: camss: csid: Add support for 8x74
media: camss: ispif: Add support for 8x74
media: camss: csiphy: Add support for 8x74
media: camss: Add 8x74 resources
i2c: qcom-cci: add msm8974 compatible

.../devicetree/bindings/i2c/i2c-qcom-cci.txt | 7 +-
.../bindings/media/qcom,msm8974-camss.yaml | 321 ++++++++++++++++++
arch/arm/boot/dts/qcom-msm8974.dtsi | 184 ++++++++++
.../dts/qcom-msm8974pro-fairphone-fp2.dts | 70 ++++
drivers/i2c/busses/i2c-qcom-cci.c | 35 ++
drivers/media/platform/qcom/camss/Kconfig | 4 +-
.../media/platform/qcom/camss/camss-csid.c | 3 +-
.../media/platform/qcom/camss/camss-csiphy.c | 4 +-
.../media/platform/qcom/camss/camss-ispif.c | 5 +-
drivers/media/platform/qcom/camss/camss-vfe.c | 7 +-
.../media/platform/qcom/camss/camss-video.c | 17 +-
drivers/media/platform/qcom/camss/camss.c | 161 +++++++++
drivers/media/platform/qcom/camss/camss.h | 1 +
13 files changed, 801 insertions(+), 18 deletions(-)
create mode 100644 Documentation/devicetree/bindings/media/qcom,msm8974-camss.yaml

--
2.36.0



2022-05-23 07:59:34

by Luca Weiss

[permalink] [raw]
Subject: [RFC PATCH 13/14] ARM: dts: qcom: msm8974-FP2: Add OV8865 rear camera

Configure the rear camera found in the 8MP camera module for
Fairphone 2. There's also a AD5823 autofocus coil and an EEPROM present
on the module but currently not included.

Signed-off-by: Luca Weiss <[email protected]>
---
.../dts/qcom-msm8974pro-fairphone-fp2.dts | 70 +++++++++++++++++++
1 file changed, 70 insertions(+)

diff --git a/arch/arm/boot/dts/qcom-msm8974pro-fairphone-fp2.dts b/arch/arm/boot/dts/qcom-msm8974pro-fairphone-fp2.dts
index 0fad82fc9e03..9a2c3a9177de 100644
--- a/arch/arm/boot/dts/qcom-msm8974pro-fairphone-fp2.dts
+++ b/arch/arm/boot/dts/qcom-msm8974pro-fairphone-fp2.dts
@@ -77,6 +77,60 @@ &blsp1_uart2 {
status = "okay";
};

+&camss {
+ status = "okay";
+
+ vdda-supply = <&pm8941_l12>;
+
+ ports {
+ port@0 {
+ reg = <0>;
+ csiphy0_ep: endpoint {
+ clock-lanes = <1>;
+ data-lanes = <0 2 3 4>;
+ link-frequencies = /bits/ 64 <360000000>;
+ remote-endpoint = <&ov8865_ep>;
+ };
+ };
+ };
+};
+
+&cci {
+ status = "okay";
+};
+
+&cci_i2c0 {
+ ov8865: camera-sensor@10 {
+ compatible = "ovti,ov8865";
+ reg = <0x10>;
+
+ pinctrl-names = "default";
+ pinctrl-0 = <&mclk0_pin_a>;
+
+ clocks = <&mmcc CAMSS_MCLK0_CLK>;
+
+ avdd-supply = <&pm8941_l17>;
+ dovdd-supply = <&pm8941_lvs3>;
+ dvdd-supply = <&pm8941_l3>;
+
+ powerdown-gpios = <&tlmm 89 GPIO_ACTIVE_LOW>;
+ reset-gpios = <&tlmm 90 GPIO_ACTIVE_LOW>;
+
+ /* Rear camera */
+ orientation = <1>;
+ rotation = <90>;
+
+ port {
+ ov8865_ep: endpoint {
+ clock-lanes = <1>;
+ data-lanes = <0 2 3 4>;
+ link-frequencies = /bits/ 64 <360000000>;
+ remote-endpoint = <&csiphy0_ep>;
+ };
+ };
+ };
+};
+
&dsi0 {
status = "okay";

@@ -413,6 +467,15 @@ pm8941_l24: l24 {
regulator-max-microvolt = <3075000>;
regulator-boot-on;
};
+
+ pm8941_lvs3: lvs3 {
+ /*
+ * TODO: Used as CCI0 and CCI1 pull-up.
+ * Replace with vbus-supply or similar once this lands
+ * upstream!
+ */
+ regulator-always-on;
+ };
};
};

@@ -449,6 +512,13 @@ &smbb {
};

&tlmm {
+ mclk0_pin_a: mclk0-pin-active {
+ pins = "gpio15";
+ function = "cam_mclk0";
+ drive-strength = <2>;
+ bias-disable;
+ };
+
panel_pin: panel {
te {
pins = "gpio12";
--
2.36.0


2022-05-23 08:04:37

by Luca Weiss

[permalink] [raw]
Subject: [RFC PATCH 10/14] i2c: qcom-cci: add msm8974 compatible

From: Matti Lehtimäki <[email protected]>

MSM8974 CCI is the same as MSM8916 except it has two masters.

Signed-off-by: Matti Lehtimäki <[email protected]>
Signed-off-by: Luca Weiss <[email protected]>
---
To note, the cci_v1_5_data variable name is just a bit arbitrary and
isn't meant to reflect IP version "1.5". I'd be happy to change the
variable name to something else.

drivers/i2c/busses/i2c-qcom-cci.c | 35 +++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)

diff --git a/drivers/i2c/busses/i2c-qcom-cci.c b/drivers/i2c/busses/i2c-qcom-cci.c
index 5c7cc862f08f..a68f17eb9dd0 100644
--- a/drivers/i2c/busses/i2c-qcom-cci.c
+++ b/drivers/i2c/busses/i2c-qcom-cci.c
@@ -725,6 +725,40 @@ static const struct cci_data cci_v1_data = {
},
};

+static const struct cci_data cci_v1_5_data = {
+ .num_masters = 2,
+ .queue_size = { 64, 16 },
+ .quirks = {
+ .max_write_len = 10,
+ .max_read_len = 12,
+ },
+ .cci_clk_rate = 19200000,
+ .params[I2C_MODE_STANDARD] = {
+ .thigh = 78,
+ .tlow = 114,
+ .tsu_sto = 28,
+ .tsu_sta = 28,
+ .thd_dat = 10,
+ .thd_sta = 77,
+ .tbuf = 118,
+ .scl_stretch_en = 0,
+ .trdhld = 6,
+ .tsp = 1
+ },
+ .params[I2C_MODE_FAST] = {
+ .thigh = 20,
+ .tlow = 28,
+ .tsu_sto = 21,
+ .tsu_sta = 21,
+ .thd_dat = 13,
+ .thd_sta = 18,
+ .tbuf = 32,
+ .scl_stretch_en = 0,
+ .trdhld = 6,
+ .tsp = 3
+ },
+};
+
static const struct cci_data cci_v2_data = {
.num_masters = 2,
.queue_size = { 64, 16 },
@@ -773,6 +807,7 @@ static const struct cci_data cci_v2_data = {

static const struct of_device_id cci_dt_match[] = {
{ .compatible = "qcom,msm8916-cci", .data = &cci_v1_data},
+ { .compatible = "qcom,msm8974-cci", .data = &cci_v1_5_data},
{ .compatible = "qcom,msm8996-cci", .data = &cci_v2_data},
{ .compatible = "qcom,sdm845-cci", .data = &cci_v2_data},
{ .compatible = "qcom,sm8250-cci", .data = &cci_v2_data},
--
2.36.0


2022-05-23 08:09:57

by Luca Weiss

[permalink] [raw]
Subject: [RFC PATCH 03/14] media: camss: vfe: Add support for 8x74

From: Matti Lehtimäki <[email protected]>

VFE hardware modules on 8x74 and 8x16 are similar.

Signed-off-by: Matti Lehtimäki <[email protected]>
Signed-off-by: Luca Weiss <[email protected]>
---
drivers/media/platform/qcom/camss/camss-vfe.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c
index 5b148e9f8134..ace53ed24884 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe.c
@@ -170,7 +170,8 @@ static u32 vfe_src_pad_code(struct vfe_line *line, u32 sink_code,
{
struct vfe_device *vfe = to_vfe(line);

- if (vfe->camss->version == CAMSS_8x16)
+ if (vfe->camss->version == CAMSS_8x16 ||
+ vfe->camss->version == CAMSS_8x74)
switch (sink_code) {
case MEDIA_BUS_FMT_YUYV8_2X8:
{
@@ -1286,6 +1287,7 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe,

switch (camss->version) {
case CAMSS_8x16:
+ case CAMSS_8x74:
vfe->ops = &vfe_ops_4_1;
break;
case CAMSS_8x96:
@@ -1390,7 +1392,8 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe,
init_completion(&l->output.sof);
init_completion(&l->output.reg_update);

- if (camss->version == CAMSS_8x16) {
+ if (camss->version == CAMSS_8x16 ||
+ camss->version == CAMSS_8x74) {
if (i == VFE_LINE_PIX) {
l->formats = formats_pix_8x16;
l->nformats = ARRAY_SIZE(formats_pix_8x16);
--
2.36.0


2022-05-23 08:13:23

by Luca Weiss

[permalink] [raw]
Subject: [RFC PATCH 07/14] media: camss: csiphy: Add support for 8x74

From: Matti Lehtimäki <[email protected]>

CSIPHY hardware modules in 8x74 and 8x16 are similar.

Signed-off-by: Matti Lehtimäki <[email protected]>
Signed-off-by: Luca Weiss <[email protected]>
---
drivers/media/platform/qcom/camss/camss-csiphy.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/media/platform/qcom/camss/camss-csiphy.c
index 75fcfc627400..a0122705a874 100644
--- a/drivers/media/platform/qcom/camss/camss-csiphy.c
+++ b/drivers/media/platform/qcom/camss/camss-csiphy.c
@@ -557,7 +557,8 @@ int msm_csiphy_subdev_init(struct camss *camss,
csiphy->id = id;
csiphy->cfg.combo_mode = 0;

- if (camss->version == CAMSS_8x16) {
+ if (camss->version == CAMSS_8x16 ||
+ camss->version == CAMSS_8x74) {
csiphy->ops = &csiphy_ops_2ph_1_0;
csiphy->formats = csiphy_formats_8x16;
csiphy->nformats = ARRAY_SIZE(csiphy_formats_8x16);
@@ -582,6 +583,7 @@ int msm_csiphy_subdev_init(struct camss *camss,
return PTR_ERR(csiphy->base);

if (camss->version == CAMSS_8x16 ||
+ camss->version == CAMSS_8x74 ||
camss->version == CAMSS_8x96) {
csiphy->base_clk_mux =
devm_platform_ioremap_resource_byname(pdev, res->reg[1]);
--
2.36.0


2022-05-23 08:17:51

by Luca Weiss

[permalink] [raw]
Subject: [RFC PATCH 08/14] media: camss: Add 8x74 resources

From: Matti Lehtimäki <[email protected]>

Add structs with 8x74 resources. The number of CSIPHY, CSID
and VFE hardware modules is the same as 8x96 but the support
is otherwise different.

Signed-off-by: Matti Lehtimäki <[email protected]>
Signed-off-by: Luca Weiss <[email protected]>
---
drivers/media/platform/qcom/camss/camss.c | 161 ++++++++++++++++++++++
1 file changed, 161 insertions(+)

diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
index 79ad82e233cb..5a69ce48c792 100644
--- a/drivers/media/platform/qcom/camss/camss.c
+++ b/drivers/media/platform/qcom/camss/camss.c
@@ -126,6 +126,154 @@ static const struct resources vfe_res_8x16[] = {
}
};

+static const struct resources csiphy_res_8974[] = {
+ /* CSIPHY0 */
+ {
+ .regulators = { NULL },
+ .clock = { "top_ahb", "ispif_ahb", "csiphy0_timer" },
+ .clock_rate = { { 0 },
+ { 0 },
+ { 100000000, 200000000 } },
+ .reg = { "csiphy0", "csiphy0_clk_mux" },
+ .interrupt = { "csiphy0" }
+ },
+
+ /* CSIPHY1 */
+ {
+ .regulators = { NULL },
+ .clock = { "top_ahb", "ispif_ahb", "csiphy1_timer" },
+ .clock_rate = { { 0 },
+ { 0 },
+ { 100000000, 200000000 } },
+ .reg = { "csiphy1", "csiphy1_clk_mux" },
+ .interrupt = { "csiphy1" }
+ },
+
+ /* CSIPHY2 */
+ {
+ .regulators = { NULL },
+ .clock = { "top_ahb", "ispif_ahb", "csiphy2_timer" },
+ .clock_rate = { { 0 },
+ { 0 },
+ { 100000000, 200000000 } },
+ .reg = { "csiphy2", "csiphy2_clk_mux" },
+ .interrupt = { "csiphy2" }
+ }
+};
+
+static const struct resources csid_res_8974[] = {
+ /* CSID0 */
+ {
+ .regulators = { "vdda" },
+ .clock = { "top_ahb", "ispif_ahb", "csi0_ahb",
+ "csi0", "csi0_phy", "csi0_pix", "csi0_rdi" },
+ .clock_rate = { { 0 },
+ { 0 },
+ { 0 },
+ { 100000000, 200000000 },
+ { 0 },
+ { 0 },
+ { 0 } },
+ .reg = { "csid0" },
+ .interrupt = { "csid0" }
+ },
+
+ /* CSID1 */
+ {
+ .regulators = { "vdda" },
+ .clock = { "top_ahb", "ispif_ahb", "csi1_ahb",
+ "csi1", "csi1_phy", "csi1_pix", "csi1_rdi" },
+ .clock_rate = { { 0 },
+ { 0 },
+ { 0 },
+ { 100000000, 200000000 },
+ { 0 },
+ { 0 },
+ { 0 } },
+ .reg = { "csid1" },
+ .interrupt = { "csid1" }
+ },
+
+ /* CSID2 */
+ {
+ .regulators = { "vdda" },
+ .clock = { "top_ahb", "ispif_ahb", "csi2_ahb",
+ "csi2", "csi2_phy", "csi2_pix", "csi2_rdi" },
+ .clock_rate = { { 0 },
+ { 0 },
+ { 0 },
+ { 100000000, 200000000 },
+ { 0 },
+ { 0 },
+ { 0 } },
+ .reg = { "csid2" },
+ .interrupt = { "csid2" }
+ },
+
+ /* CSID3 */
+ {
+ .regulators = { "vdda" },
+ .clock = { "top_ahb", "ispif_ahb", "csi3_ahb",
+ "csi3", "csi3_phy", "csi3_pix", "csi3_rdi" },
+ .clock_rate = { { 0 },
+ { 0 },
+ { 0 },
+ { 100000000, 200000000 },
+ { 0 },
+ { 0 },
+ { 0 } },
+ .reg = { "csid3" },
+ .interrupt = { "csid3" }
+ }
+};
+
+static const struct resources_ispif ispif_res_8974 = {
+ /* ISPIF */
+ .clock = { "top_ahb", "ispif_ahb",
+ "csi0", "csi0_pix", "csi0_rdi",
+ "csi1", "csi1_pix", "csi1_rdi",
+ "csi2", "csi2_pix", "csi2_rdi",
+ "csi3", "csi3_pix", "csi3_rdi" },
+ .clock_for_reset = { "vfe0", "csi_vfe0",
+ "vfe1", "csi_vfe1" },
+ .reg = { "ispif", "csi_clk_mux" },
+ .interrupt = "ispif"
+
+};
+
+static const struct resources vfe_res_8974[] = {
+ /* VFE0 */
+ {
+ .regulators = { NULL },
+ .clock = { "top_ahb", "vfe0", "csi_vfe0",
+ "iface", "bus" },
+ .clock_rate = { { 0 },
+ { 50000000, 80000000, 100000000, 160000000,
+ 177780000, 200000000, 266670000, 320000000,
+ 400000000, 400000000 },
+ { 0 },
+ { 0 },
+ { 0 } },
+ .reg = { "vfe0" },
+ .interrupt = { "vfe0" }
+ },
+ /* VFE1 */
+ {
+ .regulators = { NULL },
+ .clock = { "top_ahb", "vfe1", "csi_vfe1",
+ "iface", "bus" },
+ .clock_rate = { { 0 },
+ { 50000000, 80000000, 100000000, 160000000,
+ 177780000, 200000000, 266670000, 320000000,
+ 400000000, 400000000 },
+ { 0 },
+ { 0 },
+ { 0 } },
+ .reg = { "vfe1" },
+ .interrupt = { "vfe1" }
+ }
+};
+
static const struct resources csiphy_res_8x96[] = {
/* CSIPHY0 */
{
@@ -1132,6 +1280,11 @@ static int camss_init_subdevices(struct camss *camss)
csid_res = csid_res_8x16;
ispif_res = &ispif_res_8x16;
vfe_res = vfe_res_8x16;
+ } else if (camss->version == CAMSS_8x74) {
+ csiphy_res = csiphy_res_8974;
+ csid_res = csid_res_8974;
+ ispif_res = &ispif_res_8974;
+ vfe_res = vfe_res_8974;
} else if (camss->version == CAMSS_8x96) {
csiphy_res = csiphy_res_8x96;
csid_res = csid_res_8x96;
@@ -1542,6 +1695,12 @@ static int camss_probe(struct platform_device *pdev)
camss->csiphy_num = 2;
camss->csid_num = 2;
camss->vfe_num = 1;
+ } else if (of_device_is_compatible(dev->of_node,
+ "qcom,msm8974-camss")) {
+ camss->version = CAMSS_8x74;
+ camss->csiphy_num = 3;
+ camss->csid_num = 4;
+ camss->vfe_num = 2;
} else if (of_device_is_compatible(dev->of_node,
"qcom,msm8996-camss")) {
camss->version = CAMSS_8x96;
@@ -1586,6 +1745,7 @@ static int camss_probe(struct platform_device *pdev)
}

if (camss->version == CAMSS_8x16 ||
+ camss->version == CAMSS_8x74 ||
camss->version == CAMSS_8x96) {
camss->ispif = devm_kcalloc(dev, 1, sizeof(*camss->ispif), GFP_KERNEL);
if (!camss->ispif) {
@@ -1735,6 +1895,7 @@ static int camss_remove(struct platform_device *pdev)

static const struct of_device_id camss_dt_match[] = {
{ .compatible = "qcom,msm8916-camss" },
+ { .compatible = "qcom,msm8974-camss" },
{ .compatible = "qcom,msm8996-camss" },
{ .compatible = "qcom,sdm660-camss" },
{ .compatible = "qcom,sdm845-camss" },
--
2.36.0


2022-05-23 08:19:06

by Luca Weiss

[permalink] [raw]
Subject: [RFC PATCH 04/14] media: camss: video: Add support for 8x74

From: Matti Lehtimäki <[email protected]>

Video formats in 8x16 and 8x74 are similar.

Signed-off-by: Matti Lehtimäki <[email protected]>
Signed-off-by: Luca Weiss <[email protected]>
---
drivers/media/platform/qcom/camss/camss-video.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c
index 307bb1dc4589..ca955808fd6d 100644
--- a/drivers/media/platform/qcom/camss/camss-video.c
+++ b/drivers/media/platform/qcom/camss/camss-video.c
@@ -990,7 +990,8 @@ int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev,

mutex_init(&video->lock);

- if (video->camss->version == CAMSS_8x16) {
+ if (video->camss->version == CAMSS_8x16 ||
+ video->camss->version == CAMSS_8x74) {
if (is_pix) {
video->formats = formats_pix_8x16;
video->nformats = ARRAY_SIZE(formats_pix_8x16);
--
2.36.0


2022-05-23 12:40:26

by Dmitry Baryshkov

[permalink] [raw]
Subject: Re: [RFC PATCH 00/14] CAMSS support for MSM8974

On 22/05/2022 19:27, Luca Weiss wrote:
> This RFC series adds support for CAMSS and CCI that are found on
> msm8974, including the OV8865 found on the FP2.
>
> The only reason it's marked RFC is that CAMSS doesn't behave properly on
> this SoC without the last commit which is obviously not upstreamable.
> Not sure if this should be a blocker for including most of the other
> patches because other than that it seems to work fine and I can get a
> picture from the camera sensor. When/if msm8974 gets IOMMU support I
> hope this should be resolved and it works without this hack.
>
> I think at least the CCI patches could get applied as they're not
> dependent on the CAMSS hack?

I'd also vote for the camcc patches to be applied.

As for the camss, I'd suggest to get them verified to work properly with
a hacked/non-upstreamable/etc. IOMMU driver if one exists. Otherwise we
can easily get into a situation where we merge up code that contains
bugs itself.

Another option might be to actually check whether the device has an
IOMMU attached (see device_iommu_mapped()) and to select whether the
driver should use SG or CONTIG depending on that.

As an additional note regarding the offset issue you've mentioned. It
looks like there is an issue with the swiotlb. On the IFC6410 (apq8064,
no IOMMU) I got an issue with the PCI-attached networking card. Received
packets are offset by 4 (IIRC) bytes. The same type of adapter works on
db820c (apq8096, working IOMMU). What kind of issues did you observe
with the camss? If it looks like the issue I had, it might be a symptom
of a more generic issue.

>
> Luca Weiss (5):
> dt-bindings: i2c: qcom-cci: add QCOM MSM8974 compatible
> ARM: dts: qcom: msm8974: add CCI bus
> ARM: dts: qcom: msm8974: add CAMSS node
> ARM: dts: qcom: msm8974-FP2: Add OV8865 rear camera
> [DNM] media: camss: hacks for MSM8974
>
> Matti Lehtimäki (9):
> media: dt-bindings: media: camss: Add qcom,msm8974-camss binding
> media: camss: Add CAMSS_8x74 camss version
> media: camss: vfe: Add support for 8x74
> media: camss: video: Add support for 8x74
> media: camss: csid: Add support for 8x74
> media: camss: ispif: Add support for 8x74
> media: camss: csiphy: Add support for 8x74
> media: camss: Add 8x74 resources
> i2c: qcom-cci: add msm8974 compatible
>
> .../devicetree/bindings/i2c/i2c-qcom-cci.txt | 7 +-
> .../bindings/media/qcom,msm8974-camss.yaml | 321 ++++++++++++++++++
> arch/arm/boot/dts/qcom-msm8974.dtsi | 184 ++++++++++
> .../dts/qcom-msm8974pro-fairphone-fp2.dts | 70 ++++
> drivers/i2c/busses/i2c-qcom-cci.c | 35 ++
> drivers/media/platform/qcom/camss/Kconfig | 4 +-
> .../media/platform/qcom/camss/camss-csid.c | 3 +-
> .../media/platform/qcom/camss/camss-csiphy.c | 4 +-
> .../media/platform/qcom/camss/camss-ispif.c | 5 +-
> drivers/media/platform/qcom/camss/camss-vfe.c | 7 +-
> .../media/platform/qcom/camss/camss-video.c | 17 +-
> drivers/media/platform/qcom/camss/camss.c | 161 +++++++++
> drivers/media/platform/qcom/camss/camss.h | 1 +
> 13 files changed, 801 insertions(+), 18 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/media/qcom,msm8974-camss.yaml
>


--
With best wishes
Dmitry

2022-05-23 18:48:51

by Brian Masney

[permalink] [raw]
Subject: Re: [RFC PATCH 00/14] CAMSS support for MSM8974

On Mon, May 23, 2022 at 03:39:53PM +0300, Dmitry Baryshkov wrote:
> On 22/05/2022 19:27, Luca Weiss wrote:
> > This RFC series adds support for CAMSS and CCI that are found on
> > msm8974, including the OV8865 found on the FP2.
> >
> > The only reason it's marked RFC is that CAMSS doesn't behave properly on
> > this SoC without the last commit which is obviously not upstreamable.
> > Not sure if this should be a blocker for including most of the other
> > patches because other than that it seems to work fine and I can get a
> > picture from the camera sensor. When/if msm8974 gets IOMMU support I
> > hope this should be resolved and it works without this hack.
> >
> > I think at least the CCI patches could get applied as they're not
> > dependent on the CAMSS hack?
>
> I'd also vote for the camcc patches to be applied.
>
> As for the camss, I'd suggest to get them verified to work properly with a
> hacked/non-upstreamable/etc. IOMMU driver if one exists. Otherwise we can
> easily get into a situation where we merge up code that contains bugs
> itself.

Last I checked, there's no IOMMU driver for msm8974 that works with an
upstream kernel at the moment. About 2 years ago, I took a stab at
attempting to enable IOMMU for the display and ran into some issues that
I documented at:

https://lore.kernel.org/lkml/[email protected]/

I'm not familiar with this part of the hardware and haven't had time
since then to look into this further.

Brian


2022-05-26 21:49:28

by Robert Foss

[permalink] [raw]
Subject: Re: [RFC PATCH 08/14] media: camss: Add 8x74 resources

On Sun, 22 May 2022 at 18:28, Luca Weiss <[email protected]> wrote:
>
> From: Matti Lehtimäki <[email protected]>
>
> Add structs with 8x74 resources. The number of CSIPHY, CSID
> and VFE hardware modules is the same as 8x96 but the support
> is otherwise different.
>
> Signed-off-by: Matti Lehtimäki <[email protected]>
> Signed-off-by: Luca Weiss <[email protected]>
> ---
> drivers/media/platform/qcom/camss/camss.c | 161 ++++++++++++++++++++++
> 1 file changed, 161 insertions(+)
>
> diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
> index 79ad82e233cb..5a69ce48c792 100644
> --- a/drivers/media/platform/qcom/camss/camss.c
> +++ b/drivers/media/platform/qcom/camss/camss.c
> @@ -126,6 +126,154 @@ static const struct resources vfe_res_8x16[] = {
> }
> };
>
> +static const struct resources csiphy_res_8974[] = {
> + /* CSIPHY0 */
> + {
> + .regulators = { NULL },
> + .clock = { "top_ahb", "ispif_ahb", "csiphy0_timer" },
> + .clock_rate = { { 0 },
> + { 0 },
> + { 100000000, 200000000 } },
> + .reg = { "csiphy0", "csiphy0_clk_mux" },
> + .interrupt = { "csiphy0" }
> + },
> +
> + /* CSIPHY1 */
> + {
> + .regulators = { NULL },
> + .clock = { "top_ahb", "ispif_ahb", "csiphy1_timer" },
> + .clock_rate = { { 0 },
> + { 0 },
> + { 100000000, 200000000 } },
> + .reg = { "csiphy1", "csiphy1_clk_mux" },
> + .interrupt = { "csiphy1" }
> + },
> +
> + /* CSIPHY2 */
> + {
> + .regulators = { NULL },
> + .clock = { "top_ahb", "ispif_ahb", "csiphy2_timer" },
> + .clock_rate = { { 0 },
> + { 0 },
> + { 100000000, 200000000 } },
> + .reg = { "csiphy2", "csiphy2_clk_mux" },
> + .interrupt = { "csiphy2" }
> + }
> +};
> +
> +static const struct resources csid_res_8974[] = {
> + /* CSID0 */
> + {
> + .regulators = { "vdda" },
> + .clock = { "top_ahb", "ispif_ahb", "csi0_ahb",
> + "csi0", "csi0_phy", "csi0_pix", "csi0_rdi" },
> + .clock_rate = { { 0 },
> + { 0 },
> + { 0 },
> + { 100000000, 200000000 },
> + { 0 },
> + { 0 },
> + { 0 } },
> + .reg = { "csid0" },
> + .interrupt = { "csid0" }
> + },
> +
> + /* CSID1 */
> + {
> + .regulators = { "vdda" },
> + .clock = { "top_ahb", "ispif_ahb", "csi1_ahb",
> + "csi1", "csi1_phy", "csi1_pix", "csi1_rdi" },
> + .clock_rate = { { 0 },
> + { 0 },
> + { 0 },
> + { 100000000, 200000000 },
> + { 0 },
> + { 0 },
> + { 0 } },
> + .reg = { "csid1" },
> + .interrupt = { "csid1" }
> + },
> +
> + /* CSID2 */
> + {
> + .regulators = { "vdda" },
> + .clock = { "top_ahb", "ispif_ahb", "csi2_ahb",
> + "csi2", "csi2_phy", "csi2_pix", "csi2_rdi" },
> + .clock_rate = { { 0 },
> + { 0 },
> + { 0 },
> + { 100000000, 200000000 },
> + { 0 },
> + { 0 },
> + { 0 } },
> + .reg = { "csid2" },
> + .interrupt = { "csid2" }
> + },
> +
> + /* CSID3 */
> + {
> + .regulators = { "vdda" },
> + .clock = { "top_ahb", "ispif_ahb", "csi3_ahb",
> + "csi3", "csi3_phy", "csi3_pix", "csi3_rdi" },
> + .clock_rate = { { 0 },
> + { 0 },
> + { 0 },
> + { 100000000, 200000000 },
> + { 0 },
> + { 0 },
> + { 0 } },
> + .reg = { "csid3" },
> + .interrupt = { "csid3" }
> + }
> +};
> +
> +static const struct resources_ispif ispif_res_8974 = {
> + /* ISPIF */
> + .clock = { "top_ahb", "ispif_ahb",
> + "csi0", "csi0_pix", "csi0_rdi",
> + "csi1", "csi1_pix", "csi1_rdi",
> + "csi2", "csi2_pix", "csi2_rdi",
> + "csi3", "csi3_pix", "csi3_rdi" },
> + .clock_for_reset = { "vfe0", "csi_vfe0",
> + "vfe1", "csi_vfe1" },
> + .reg = { "ispif", "csi_clk_mux" },
> + .interrupt = "ispif"
> +
> +};
> +
> +static const struct resources vfe_res_8974[] = {
> + /* VFE0 */
> + {
> + .regulators = { NULL },
> + .clock = { "top_ahb", "vfe0", "csi_vfe0",
> + "iface", "bus" },
> + .clock_rate = { { 0 },
> + { 50000000, 80000000, 100000000, 160000000,
> + 177780000, 200000000, 266670000, 320000000,
> + 400000000, 400000000 },
> + { 0 },
> + { 0 },
> + { 0 } },
> + .reg = { "vfe0" },
> + .interrupt = { "vfe0" }
> + },
> + /* VFE1 */
> + {
> + .regulators = { NULL },
> + .clock = { "top_ahb", "vfe1", "csi_vfe1",
> + "iface", "bus" },
> + .clock_rate = { { 0 },
> + { 50000000, 80000000, 100000000, 160000000,
> + 177780000, 200000000, 266670000, 320000000,
> + 400000000, 400000000 },
> + { 0 },
> + { 0 },
> + { 0 } },
> + .reg = { "vfe1" },
> + .interrupt = { "vfe1" }
> + }
> +};
> +
> static const struct resources csiphy_res_8x96[] = {
> /* CSIPHY0 */
> {
> @@ -1132,6 +1280,11 @@ static int camss_init_subdevices(struct camss *camss)
> csid_res = csid_res_8x16;
> ispif_res = &ispif_res_8x16;
> vfe_res = vfe_res_8x16;
> + } else if (camss->version == CAMSS_8x74) {
> + csiphy_res = csiphy_res_8974;
> + csid_res = csid_res_8974;
> + ispif_res = &ispif_res_8974;
> + vfe_res = vfe_res_8974;
> } else if (camss->version == CAMSS_8x96) {
> csiphy_res = csiphy_res_8x96;
> csid_res = csid_res_8x96;
> @@ -1542,6 +1695,12 @@ static int camss_probe(struct platform_device *pdev)
> camss->csiphy_num = 2;
> camss->csid_num = 2;
> camss->vfe_num = 1;
> + } else if (of_device_is_compatible(dev->of_node,
> + "qcom,msm8974-camss")) {
> + camss->version = CAMSS_8x74;
> + camss->csiphy_num = 3;
> + camss->csid_num = 4;
> + camss->vfe_num = 2;
> } else if (of_device_is_compatible(dev->of_node,
> "qcom,msm8996-camss")) {
> camss->version = CAMSS_8x96;
> @@ -1586,6 +1745,7 @@ static int camss_probe(struct platform_device *pdev)
> }
>
> if (camss->version == CAMSS_8x16 ||
> + camss->version == CAMSS_8x74 ||
> camss->version == CAMSS_8x96) {
> camss->ispif = devm_kcalloc(dev, 1, sizeof(*camss->ispif), GFP_KERNEL);
> if (!camss->ispif) {
> @@ -1735,6 +1895,7 @@ static int camss_remove(struct platform_device *pdev)
>
> static const struct of_device_id camss_dt_match[] = {
> { .compatible = "qcom,msm8916-camss" },
> + { .compatible = "qcom,msm8974-camss" },
> { .compatible = "qcom,msm8996-camss" },
> { .compatible = "qcom,sdm660-camss" },
> { .compatible = "qcom,sdm845-camss" },
> --
> 2.36.0
>

Reviewed-by: Robert Foss <[email protected]>

2022-05-27 12:38:43

by Robert Foss

[permalink] [raw]
Subject: Re: [RFC PATCH 07/14] media: camss: csiphy: Add support for 8x74

On Sun, 22 May 2022 at 18:28, Luca Weiss <[email protected]> wrote:
>
> From: Matti Lehtimäki <[email protected]>
>
> CSIPHY hardware modules in 8x74 and 8x16 are similar.
>
> Signed-off-by: Matti Lehtimäki <[email protected]>
> Signed-off-by: Luca Weiss <[email protected]>
> ---
> drivers/media/platform/qcom/camss/camss-csiphy.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/media/platform/qcom/camss/camss-csiphy.c
> index 75fcfc627400..a0122705a874 100644
> --- a/drivers/media/platform/qcom/camss/camss-csiphy.c
> +++ b/drivers/media/platform/qcom/camss/camss-csiphy.c
> @@ -557,7 +557,8 @@ int msm_csiphy_subdev_init(struct camss *camss,
> csiphy->id = id;
> csiphy->cfg.combo_mode = 0;
>
> - if (camss->version == CAMSS_8x16) {
> + if (camss->version == CAMSS_8x16 ||
> + camss->version == CAMSS_8x74) {

CHECK: Alignment should match open parenthesis
#27: FILE: drivers/media/platform/qcom/camss/camss-csiphy.c:561:
+ if (camss->version == CAMSS_8x16 ||
+ camss->version == CAMSS_8x74) {


> csiphy->ops = &csiphy_ops_2ph_1_0;
> csiphy->formats = csiphy_formats_8x16;
> csiphy->nformats = ARRAY_SIZE(csiphy_formats_8x16);
> @@ -582,6 +583,7 @@ int msm_csiphy_subdev_init(struct camss *camss,
> return PTR_ERR(csiphy->base);
>
> if (camss->version == CAMSS_8x16 ||
> + camss->version == CAMSS_8x74 ||
> camss->version == CAMSS_8x96) {
> csiphy->base_clk_mux =
> devm_platform_ioremap_resource_byname(pdev, res->reg[1]);
> --
> 2.36.0
>

With that fixed:
Reviewed-by: Robert Foss <[email protected]>

2022-05-28 09:56:05

by Robert Foss

[permalink] [raw]
Subject: Re: [RFC PATCH 04/14] media: camss: video: Add support for 8x74

On Sun, 22 May 2022 at 18:28, Luca Weiss <[email protected]> wrote:
>
> From: Matti Lehtimäki <[email protected]>
>
> Video formats in 8x16 and 8x74 are similar.
>
> Signed-off-by: Matti Lehtimäki <[email protected]>
> Signed-off-by: Luca Weiss <[email protected]>
> ---
> drivers/media/platform/qcom/camss/camss-video.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c
> index 307bb1dc4589..ca955808fd6d 100644
> --- a/drivers/media/platform/qcom/camss/camss-video.c
> +++ b/drivers/media/platform/qcom/camss/camss-video.c
> @@ -990,7 +990,8 @@ int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev,
>
> mutex_init(&video->lock);
>
> - if (video->camss->version == CAMSS_8x16) {
> + if (video->camss->version == CAMSS_8x16 ||
> + video->camss->version == CAMSS_8x74) {

#27: FILE: drivers/media/platform/qcom/camss/camss-video.c:994:
+ if (video->camss->version == CAMSS_8x16 ||
+ video->camss->version == CAMSS_8x74) {


> if (is_pix) {
> video->formats = formats_pix_8x16;
> video->nformats = ARRAY_SIZE(formats_pix_8x16);
> --
> 2.36.0
>

With that fixed:

Reviewed-by: Robert Foss <[email protected]>

2022-05-28 19:39:49

by Robert Foss

[permalink] [raw]
Subject: Re: [RFC PATCH 03/14] media: camss: vfe: Add support for 8x74

On Sun, 22 May 2022 at 18:28, Luca Weiss <[email protected]> wrote:
>
> From: Matti Lehtimäki <[email protected]>
>
> VFE hardware modules on 8x74 and 8x16 are similar.
>
> Signed-off-by: Matti Lehtimäki <[email protected]>
> Signed-off-by: Luca Weiss <[email protected]>
> ---
> drivers/media/platform/qcom/camss/camss-vfe.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c
> index 5b148e9f8134..ace53ed24884 100644
> --- a/drivers/media/platform/qcom/camss/camss-vfe.c
> +++ b/drivers/media/platform/qcom/camss/camss-vfe.c
> @@ -170,7 +170,8 @@ static u32 vfe_src_pad_code(struct vfe_line *line, u32 sink_code,
> {
> struct vfe_device *vfe = to_vfe(line);
>
> - if (vfe->camss->version == CAMSS_8x16)
> + if (vfe->camss->version == CAMSS_8x16 ||
> + vfe->camss->version == CAMSS_8x74)

Match indentation of previous line.

CHECK: Alignment should match open parenthesis
#27: FILE: drivers/media/platform/qcom/camss/camss-vfe.c:174:
+ if (vfe->camss->version == CAMSS_8x16 ||
+ vfe->camss->version == CAMSS_8x74)

> switch (sink_code) {
> case MEDIA_BUS_FMT_YUYV8_2X8:
> {
> @@ -1286,6 +1287,7 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe,
>
> switch (camss->version) {
> case CAMSS_8x16:
> + case CAMSS_8x74:
> vfe->ops = &vfe_ops_4_1;
> break;
> case CAMSS_8x96:
> @@ -1390,7 +1392,8 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe,
> init_completion(&l->output.sof);
> init_completion(&l->output.reg_update);
>
> - if (camss->version == CAMSS_8x16) {
> + if (camss->version == CAMSS_8x16 ||
> + camss->version == CAMSS_8x74) {

Same

> if (i == VFE_LINE_PIX) {
> l->formats = formats_pix_8x16;
> l->nformats = ARRAY_SIZE(formats_pix_8x16);
> --
> 2.36.0
>

With that fixed:
Reviewed-by: Robert Foss <[email protected]>

2022-06-14 21:19:56

by Wolfram Sang

[permalink] [raw]
Subject: Re: [RFC PATCH 10/14] i2c: qcom-cci: add msm8974 compatible

On Sun, May 22, 2022 at 06:27:58PM +0200, Luca Weiss wrote:
> From: Matti Lehtimäki <[email protected]>
>
> MSM8974 CCI is the same as MSM8916 except it has two masters.
>
> Signed-off-by: Matti Lehtimäki <[email protected]>
> Signed-off-by: Luca Weiss <[email protected]>
> ---
> To note, the cci_v1_5_data variable name is just a bit arbitrary and
> isn't meant to reflect IP version "1.5". I'd be happy to change the
> variable name to something else.

Loic, Robert: I know this series is marked RFC, but the I2C patches
adding a new SoC to the driver are maybe interesting already?


Attachments:
(No filename) (619.00 B)
signature.asc (849.00 B)
Download all attachments

2022-06-15 17:28:43

by Loic Poulain

[permalink] [raw]
Subject: Re: [RFC PATCH 10/14] i2c: qcom-cci: add msm8974 compatible

On Sun, 22 May 2022 at 18:28, Luca Weiss <[email protected]> wrote:
>
> From: Matti Lehtimäki <[email protected]>
>
> MSM8974 CCI is the same as MSM8916 except it has two masters.
>
> Signed-off-by: Matti Lehtimäki <[email protected]>
> Signed-off-by: Luca Weiss <[email protected]>

Reviewed-by: Loic Poulain <[email protected]>

> ---
> To note, the cci_v1_5_data variable name is just a bit arbitrary and
> isn't meant to reflect IP version "1.5". I'd be happy to change the
> variable name to something else.
>
> drivers/i2c/busses/i2c-qcom-cci.c | 35 +++++++++++++++++++++++++++++++
> 1 file changed, 35 insertions(+)
>
> diff --git a/drivers/i2c/busses/i2c-qcom-cci.c b/drivers/i2c/busses/i2c-qcom-cci.c
> index 5c7cc862f08f..a68f17eb9dd0 100644
> --- a/drivers/i2c/busses/i2c-qcom-cci.c
> +++ b/drivers/i2c/busses/i2c-qcom-cci.c
> @@ -725,6 +725,40 @@ static const struct cci_data cci_v1_data = {
> },
> };
>
> +static const struct cci_data cci_v1_5_data = {
> + .num_masters = 2,
> + .queue_size = { 64, 16 },
> + .quirks = {
> + .max_write_len = 10,
> + .max_read_len = 12,
> + },
> + .cci_clk_rate = 19200000,
> + .params[I2C_MODE_STANDARD] = {
> + .thigh = 78,
> + .tlow = 114,
> + .tsu_sto = 28,
> + .tsu_sta = 28,
> + .thd_dat = 10,
> + .thd_sta = 77,
> + .tbuf = 118,
> + .scl_stretch_en = 0,
> + .trdhld = 6,
> + .tsp = 1
> + },
> + .params[I2C_MODE_FAST] = {
> + .thigh = 20,
> + .tlow = 28,
> + .tsu_sto = 21,
> + .tsu_sta = 21,
> + .thd_dat = 13,
> + .thd_sta = 18,
> + .tbuf = 32,
> + .scl_stretch_en = 0,
> + .trdhld = 6,
> + .tsp = 3
> + },
> +};
> +
> static const struct cci_data cci_v2_data = {
> .num_masters = 2,
> .queue_size = { 64, 16 },
> @@ -773,6 +807,7 @@ static const struct cci_data cci_v2_data = {
>
> static const struct of_device_id cci_dt_match[] = {
> { .compatible = "qcom,msm8916-cci", .data = &cci_v1_data},
> + { .compatible = "qcom,msm8974-cci", .data = &cci_v1_5_data},
> { .compatible = "qcom,msm8996-cci", .data = &cci_v2_data},
> { .compatible = "qcom,sdm845-cci", .data = &cci_v2_data},
> { .compatible = "qcom,sm8250-cci", .data = &cci_v2_data},
> --
> 2.36.0
>

2022-06-15 17:31:47

by Loic Poulain

[permalink] [raw]
Subject: Re: [RFC PATCH 10/14] i2c: qcom-cci: add msm8974 compatible

On Tue, 14 Jun 2022 at 22:20, Wolfram Sang <[email protected]> wrote:
>
> On Sun, May 22, 2022 at 06:27:58PM +0200, Luca Weiss wrote:
> > From: Matti Lehtimäki <[email protected]>
> >
> > MSM8974 CCI is the same as MSM8916 except it has two masters.
> >
> > Signed-off-by: Matti Lehtimäki <[email protected]>
> > Signed-off-by: Luca Weiss <[email protected]>
> > ---
> > To note, the cci_v1_5_data variable name is just a bit arbitrary and
> > isn't meant to reflect IP version "1.5". I'd be happy to change the
> > variable name to something else.
>
> Loic, Robert: I know this series is marked RFC, but the I2C patches
> adding a new SoC to the driver are maybe interesting already?

Yes I agree, no objection to get them.

Regards,
Loic