From 3f014a183b770c8cf2f928a3f07396bdfb76609f Mon Sep 17 00:00:00 2001 From: Hao Yao Date: Mon, 5 Jan 2026 16:44:19 +0800 Subject: [PATCH] PTL release for iot on 2025-12-30 Signed-off-by: Hao Yao --- .../pci/intel/ipu7/abi/ipu7_fw_isys_abi.h | 22 +---- drivers/media/pci/intel/ipu7/ipu7-fw-isys.c | 23 +---- .../media/pci/intel/ipu7/ipu7-isys-csi-phy.c | 15 +++- ...001-staging-add-ipu7-isys-reset-code.patch | 45 +++++++--- ...date-MMU-TLB-in-dma-buffers-creation.patch | 34 ++++++++ ...d-patch-for-increase-fw-msg-bufs-ini.patch | 29 ------- ...ging-add-Update-firmware-ABI-version.patch | 86 +++---------------- ...-ipu7-update-CDPHY-register-settings.patch | 80 +++++++++++++++++ 8 files changed, 174 insertions(+), 160 deletions(-) create mode 100644 patch/v6.17_iot/0007-media-ipu-invalidate-MMU-TLB-in-dma-buffers-creation.patch delete mode 100644 patch/v6.17_iot/0007-staging-add-patch-for-increase-fw-msg-bufs-ini.patch create mode 100644 patch/v6.17_iot/0021-media-ipu7-update-CDPHY-register-settings.patch diff --git a/drivers/media/pci/intel/ipu7/abi/ipu7_fw_isys_abi.h b/drivers/media/pci/intel/ipu7/abi/ipu7_fw_isys_abi.h index 171b69c..dc63449 100644 --- a/drivers/media/pci/intel/ipu7/abi/ipu7_fw_isys_abi.h +++ b/drivers/media/pci/intel/ipu7/abi/ipu7_fw_isys_abi.h @@ -352,26 +352,6 @@ struct ipu7_insys_buffset { }; struct ipu7_insys_resp { - u64 buf_id; - struct ipu7_insys_capture_output_pin_payload pin; - struct ia_gofo_msg_err error_info; - u32 timestamp[2]; - u16 mipi_fn; - u8 type; - u8 msg_link_streaming_mode; - u8 stream_id; - u8 pin_id; - u8 frame_id; - u8 skip_frame; -}; - -/** - * TODO: Revert this change after firmware ABI fixed. - * This is an internal workaround. - * IPU7.5 firmware changed its ABI and breaks - * compatibility with IPU7 Lunar Lake. - */ -struct ipu7_insys_legacy_resp { u64 buf_id; struct ipu7_insys_capture_output_pin_payload pin; struct ia_gofo_msg_err error_info; @@ -382,7 +362,7 @@ struct ipu7_insys_legacy_resp { u8 pin_id; u8 frame_id; u8 skip_frame; - u8 pad[2]; + u16 mipi_fn; }; struct ipu7_insys_resp_queue_token { diff --git a/drivers/media/pci/intel/ipu7/ipu7-fw-isys.c b/drivers/media/pci/intel/ipu7/ipu7-fw-isys.c index 26704c6..2958e39 100644 --- a/drivers/media/pci/intel/ipu7/ipu7-fw-isys.c +++ b/drivers/media/pci/intel/ipu7/ipu7-fw-isys.c @@ -195,30 +195,9 @@ int ipu7_fw_isys_close(struct ipu7_isys *isys) struct ipu7_insys_resp *ipu7_fw_isys_get_resp(struct ipu7_isys *isys) { - /** - * TODO: Revert this change after firmware ABI fixed. - * This is an internal workaround. - * IPU7.5 firmware changed its ABI and breaks - * compatibility with IPU7 Lunar Lake. - */ - struct ipu7_insys_resp *resp = + return (struct ipu7_insys_resp *) ipu7_syscom_get_token(isys->adev->syscom, IPU_INSYS_OUTPUT_MSG_QUEUE); - - if (resp && isys->adev->isp->hw_ver == IPU_VER_7) { - struct ipu7_insys_legacy_resp lnl_resp; - - memcpy(&lnl_resp, resp, sizeof(struct ipu7_insys_resp)); - resp->mipi_fn = 0; - resp->type = lnl_resp.type; - resp->msg_link_streaming_mode = lnl_resp.msg_link_streaming_mode; - resp->stream_id = lnl_resp.stream_id; - resp->pin_id = lnl_resp.pin_id; - resp->frame_id = lnl_resp.frame_id; - resp->skip_frame = lnl_resp.skip_frame; - } - - return resp; } void ipu7_fw_isys_put_resp(struct ipu7_isys *isys) diff --git a/drivers/media/pci/intel/ipu7/ipu7-isys-csi-phy.c b/drivers/media/pci/intel/ipu7/ipu7-isys-csi-phy.c index b8c5db7..97cd47d 100644 --- a/drivers/media/pci/intel/ipu7/ipu7-isys-csi-phy.c +++ b/drivers/media/pci/intel/ipu7/ipu7-isys-csi-phy.c @@ -124,6 +124,7 @@ static const struct cdr_fbk_cap_prog_params table7[] = { { 1350, 1589, 4 }, { 1590, 1949, 5 }, { 1950, 2499, 6 }, + { 2500, 3500, 7 }, { } }; @@ -730,7 +731,7 @@ static void ipu7_isys_cphy_config(struct ipu7_isys *isys, u8 id, u8 lanes, u16 deass_thresh; u16 delay_thresh; u16 reset_thresh; - u16 cap_prog = 6U; + u16 cap_prog; u16 reg; u16 val; u32 i; @@ -838,9 +839,10 @@ static void ipu7_isys_cphy_config(struct ipu7_isys *isys, u8 id, u8 lanes, dwc_phy_write_mask(isys, id, reg + 0x400 * i, reset_thresh, 9, 11); + /* Tuning ITMINRX to 2 for CPHY */ reg = CORE_DIG_CLANE_0_RW_LP_0; for (i = 0; i < trios; i++) - dwc_phy_write_mask(isys, id, reg + 0x400 * i, 1, 12, 15); + dwc_phy_write_mask(isys, id, reg + 0x400 * i, 2, 12, 15); reg = CORE_DIG_CLANE_0_RW_LP_2; for (i = 0; i < trios; i++) @@ -860,7 +862,11 @@ static void ipu7_isys_cphy_config(struct ipu7_isys *isys, u8 id, u8 lanes, for (i = 0; i < (lanes + 1); i++) { reg = CORE_DIG_IOCTRL_RW_AFE_LANE0_CTRL_2_9 + 0x400 * i; dwc_phy_write_mask(isys, id, reg, 4U, 0, 2); - dwc_phy_write_mask(isys, id, reg, 0U, 3, 4); + /* Set GMODE to 2 when CPHY >= 1.5Gsps */ + if (mbps >= 1500) + dwc_phy_write_mask(isys, id, reg, 2U, 3, 4); + else + dwc_phy_write_mask(isys, id, reg, 0U, 3, 4); reg = CORE_DIG_IOCTRL_RW_AFE_LANE0_CTRL_2_7 + 0x400 * i; dwc_phy_write_mask(isys, id, reg, cap_prog, 10, 12); @@ -930,8 +936,9 @@ static int ipu7_isys_phy_config(struct ipu7_isys *isys, u8 id, u8 lanes, 7, 12, 14); dwc_phy_write_mask(isys, id, CORE_DIG_IOCTRL_RW_AFE_CB_CTRL_2_7, 0, 8, 10); + /* resistance tuning: 1 for 45ohm, 0 for 50ohm */ dwc_phy_write_mask(isys, id, CORE_DIG_IOCTRL_RW_AFE_CB_CTRL_2_5, - 0, 8, 8); + 1, 8, 8); if (aggregation) phy_mode = isys->csi2[0].phy_mode; diff --git a/patch/v6.17_iot/0001-staging-add-ipu7-isys-reset-code.patch b/patch/v6.17_iot/0001-staging-add-ipu7-isys-reset-code.patch index 75ba2c5..5c90ae9 100644 --- a/patch/v6.17_iot/0001-staging-add-ipu7-isys-reset-code.patch +++ b/patch/v6.17_iot/0001-staging-add-ipu7-isys-reset-code.patch @@ -1,18 +1,19 @@ -From b2ab04727acd72eee42f7f6094b8d88920f43787 Mon Sep 17 00:00:00 2001 +From 147b28d7caf9418f72006ce50383c1c2c56f616b Mon Sep 17 00:00:00 2001 From: linya14x Date: Fri, 24 Oct 2025 11:46:21 +0800 Subject: [PATCH] patch: staging add ipu7 isys reset code +Change-Id: I0fadb4657fbd933e3712c7bfc5c990250e78c469 Signed-off-by: linya14x --- drivers/staging/media/ipu7/Kconfig | 10 + - drivers/staging/media/ipu7/ipu7-isys-queue.c | 359 ++++++++++++++++++- + drivers/staging/media/ipu7/ipu7-isys-queue.c | 379 ++++++++++++++++++- drivers/staging/media/ipu7/ipu7-isys-queue.h | 3 + - drivers/staging/media/ipu7/ipu7-isys-video.c | 102 ++++++ + drivers/staging/media/ipu7/ipu7-isys-video.c | 102 +++++ drivers/staging/media/ipu7/ipu7-isys-video.h | 8 + drivers/staging/media/ipu7/ipu7-isys.c | 16 + drivers/staging/media/ipu7/ipu7-isys.h | 16 + - 7 files changed, 513 insertions(+), 1 deletion(-) + 7 files changed, 533 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/ipu7/Kconfig b/drivers/staging/media/ipu7/Kconfig index 7d831ba750..c4eee7c3e6 100644 @@ -33,7 +34,7 @@ index 7d831ba750..c4eee7c3e6 100644 + + If doubt, say N here. diff --git a/drivers/staging/media/ipu7/ipu7-isys-queue.c b/drivers/staging/media/ipu7/ipu7-isys-queue.c -index 7046c29141..0c1596a2ba 100644 +index 7046c29141..1f5fb7d20d 100644 --- a/drivers/staging/media/ipu7/ipu7-isys-queue.c +++ b/drivers/staging/media/ipu7/ipu7-isys-queue.c @@ -11,6 +11,9 @@ @@ -138,7 +139,7 @@ index 7046c29141..0c1596a2ba 100644 return 0; -@@ -614,17 +660,272 @@ out_return_buffers: +@@ -614,17 +660,292 @@ out_return_buffers: return ret; } @@ -231,7 +232,17 @@ index 7046c29141..0c1596a2ba 100644 + goto out; + + bl = &__bl; -+ ret = buffer_list_get(stream, bl); ++ int retry = 5; ++ while (retry--) { ++ ret = buffer_list_get(stream, bl); ++ if (ret < 0) { ++ dev_dbg(dev, "wait for incoming buffer, retry %d\n", retry); ++ usleep_range(100000, 110000); ++ continue; ++ } ++ break; ++ } ++ + /* + * In reset start streaming and no buffer available, + * it is considered that gstreamer has been closed, @@ -288,6 +299,7 @@ index 7046c29141..0c1596a2ba 100644 + struct ipu7_isys_video *av = NULL; + struct ipu7_isys_stream *stream = NULL; + struct device *dev = &adev->auxdev.dev; ++ int ret = 0; + int i, j; + int has_streaming = 0; + const struct ipu7_isys_internal_csi2_pdata *csi2_pdata = @@ -345,8 +357,12 @@ index 7046c29141..0c1596a2ba 100644 + continue; + + av->reset = false; -+ reset_start_streaming(av); ++ ret = reset_start_streaming(av); ++ if (ret) ++ break; + } ++ if (ret) ++ break; + } + +end_of_reset: @@ -364,6 +380,7 @@ index 7046c29141..0c1596a2ba 100644 struct ipu7_isys_video *av = ipu7_isys_queue_to_video(aq); struct ipu7_isys_stream *stream = av->stream; + int ret = 0; ++ int times = 5; + + struct device *dev = &av->isys->adev->auxdev.dev; + bool need_reset; @@ -373,7 +390,7 @@ index 7046c29141..0c1596a2ba 100644 + mutex_lock(&av->isys->reset_mutex); + while (av->isys->state) { + mutex_unlock(&av->isys->reset_mutex); -+ dev_dbg(dev, "stop: %s: wait for rest or stop, isys->state = %d\n", ++ dev_dbg(dev, "stop: %s: wait for reset or stop, isys->state = %d\n", + av->vdev.name, av->isys->state); + usleep_range(10000, 11000); + mutex_lock(&av->isys->reset_mutex); @@ -388,6 +405,10 @@ index 7046c29141..0c1596a2ba 100644 + av->isys->state |= RESET_STATE_IN_STOP_STREAMING; + mutex_unlock(&av->isys->reset_mutex); + ++ while (!list_empty(&aq->active) && times--) { ++ usleep_range(30000, 31000); ++ } ++ + stream = av->stream; + if (!stream) { + dev_err(dev, "stop: %s: ip cleard!\n", av->vdev.name); @@ -412,7 +433,7 @@ index 7046c29141..0c1596a2ba 100644 stream->nr_streaming--; list_del(&aq->node); -@@ -637,7 +938,58 @@ static void stop_streaming(struct vb2_queue *q) +@@ -637,7 +958,58 @@ static void stop_streaming(struct vb2_queue *q) return_buffers(aq, VB2_BUF_STATE_ERROR); ipu7_isys_fw_close(av->isys); @@ -471,7 +492,7 @@ index 7046c29141..0c1596a2ba 100644 static unsigned int get_sof_sequence_by_timestamp(struct ipu7_isys_stream *stream, u64 time) -@@ -719,6 +1071,11 @@ static void ipu7_isys_queue_buf_done(struct ipu7_isys_buffer *ib) +@@ -719,6 +1091,11 @@ static void ipu7_isys_queue_buf_done(struct ipu7_isys_buffer *ib) * to the userspace when it is de-queued */ atomic_set(&ib->str2mmio_flag, 0); @@ -799,5 +820,5 @@ index ef1ab1b42f..17d4d56301 100644 struct isys_fw_msgs { -- -2.43.0 +2.34.1 diff --git a/patch/v6.17_iot/0007-media-ipu-invalidate-MMU-TLB-in-dma-buffers-creation.patch b/patch/v6.17_iot/0007-media-ipu-invalidate-MMU-TLB-in-dma-buffers-creation.patch new file mode 100644 index 0000000..11915c9 --- /dev/null +++ b/patch/v6.17_iot/0007-media-ipu-invalidate-MMU-TLB-in-dma-buffers-creation.patch @@ -0,0 +1,34 @@ +From 767afb431bcf19542965535d942597be0311c2e3 Mon Sep 17 00:00:00 2001 +From: hepengpx +Date: Thu, 4 Dec 2025 11:19:32 +0800 +Subject: [PATCH] media: ipu: invalidate MMU TLB in dma buffers creation + +This patch ensures that the MMU TLB is properly invalidated during +the creation and mapping of DMA buffers for IPU devices. Without +explicit invalidation, stale or incorrect entries in the TLB can cause +invalid memory access in hardware. + +Test Platform: +PTL CRB FAB B B0 silicon + +Signed-off-by: hepengpx +--- + drivers/staging/media/ipu7/ipu7-dma.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/drivers/staging/media/ipu7/ipu7-dma.c b/drivers/staging/media/ipu7/ipu7-dma.c +index a118b41b2f..a0bdf6c37f 100644 +--- a/drivers/staging/media/ipu7/ipu7-dma.c ++++ b/drivers/staging/media/ipu7/ipu7-dma.c +@@ -206,6 +206,8 @@ void *ipu7_dma_alloc(struct ipu7_bus_device *sys, size_t size, + } + } + ++ mmu->tlb_invalidate(mmu); ++ + info->vaddr = vmap(pages, count, VM_USERMAP, PAGE_KERNEL); + if (!info->vaddr) + goto out_unmap; +-- +2.34.1 + diff --git a/patch/v6.17_iot/0007-staging-add-patch-for-increase-fw-msg-bufs-ini.patch b/patch/v6.17_iot/0007-staging-add-patch-for-increase-fw-msg-bufs-ini.patch deleted file mode 100644 index 95c5a3b..0000000 --- a/patch/v6.17_iot/0007-staging-add-patch-for-increase-fw-msg-bufs-ini.patch +++ /dev/null @@ -1,29 +0,0 @@ -From ca666f9cf3084a9d3e25841d24990f6b82e473e8 Mon Sep 17 00:00:00 2001 -From: linya14x -Date: Fri, 24 Oct 2025 12:47:37 +0800 -Subject: [PATCH] patch: staging add patch for increase fw msg bufs initial - amount to 40 - -Change-Id: 09d80b512367371db6bbad83d3eaaab17dadf742 -Signed-off-by: hepengpx -Signed-off-by: linya14x ---- - drivers/staging/media/ipu7/ipu7-isys.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/staging/media/ipu7/ipu7-isys.c b/drivers/staging/media/ipu7/ipu7-isys.c -index 4282077109..10857a7206 100644 ---- a/drivers/staging/media/ipu7/ipu7-isys.c -+++ b/drivers/staging/media/ipu7/ipu7-isys.c -@@ -1075,7 +1075,7 @@ static int isys_probe(struct auxiliary_device *auxdev, - #endif - - cpu_latency_qos_add_request(&isys->pm_qos, PM_QOS_DEFAULT_VALUE); -- ret = alloc_fw_msg_bufs(isys, 20); -+ ret = alloc_fw_msg_bufs(isys, 40); - if (ret < 0) - goto out_cleanup_isys; - --- -2.43.0 - diff --git a/patch/v6.17_iot/0011-staging-add-Update-firmware-ABI-version.patch b/patch/v6.17_iot/0011-staging-add-Update-firmware-ABI-version.patch index cdb3bf1..32b69f9 100644 --- a/patch/v6.17_iot/0011-staging-add-Update-firmware-ABI-version.patch +++ b/patch/v6.17_iot/0011-staging-add-Update-firmware-ABI-version.patch @@ -1,20 +1,16 @@ -From 0719c0526372c9d710f48b21c18610d03253b5f5 Mon Sep 17 00:00:00 2001 +From de868e339dcfcbd9e7f675ae12794c24f59859db Mon Sep 17 00:00:00 2001 From: linya14x Date: Fri, 14 Nov 2025 18:41:08 +0800 Subject: [PATCH] media: ipu: Update firmware ABI version to - 1.2.1.20251028_225604 + 1.2.1.20251215_224531 -media: ipu7: Workaround for FW breaking ABI compatibility -commit-id: ab9874f2747fd6af6cee621b05341f18d6212437 -commit-id: c3b8dc8ad76895b6a9f17e705442ca19de05e76c Signed-off-by: Hao Yao Signed-off-by: linya14x --- - .../staging/media/ipu7/abi/ipu7_fw_boot_abi.h | 1 + - .../staging/media/ipu7/abi/ipu7_fw_isys_abi.h | 29 +++++++++++++++++-- - .../staging/media/ipu7/abi/ipu7_fw_msg_abi.h | 2 +- - drivers/staging/media/ipu7/ipu7-fw-isys.c | 23 ++++++++++++++- - 4 files changed, 50 insertions(+), 5 deletions(-) + drivers/staging/media/ipu7/abi/ipu7_fw_boot_abi.h | 1 + + drivers/staging/media/ipu7/abi/ipu7_fw_isys_abi.h | 11 +++++++---- + drivers/staging/media/ipu7/abi/ipu7_fw_msg_abi.h | 2 +- + 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/staging/media/ipu7/abi/ipu7_fw_boot_abi.h b/drivers/staging/media/ipu7/abi/ipu7_fw_boot_abi.h index a1519c4fe6..4ce304f54e 100644 @@ -29,7 +25,7 @@ index a1519c4fe6..4ce304f54e 100644 IA_GOFO_FW_BOOT_STATE_SHUTDOWN_START = 0x57a7e200U, IA_GOFO_FW_BOOT_STATE_INACTIVE = 0x57a7e300U, diff --git a/drivers/staging/media/ipu7/abi/ipu7_fw_isys_abi.h b/drivers/staging/media/ipu7/abi/ipu7_fw_isys_abi.h -index 45db85eb13..171b69c8c8 100644 +index c42d0b7a26..7f622bfe9a 100644 --- a/drivers/staging/media/ipu7/abi/ipu7_fw_isys_abi.h +++ b/drivers/staging/media/ipu7/abi/ipu7_fw_isys_abi.h @@ -47,7 +47,6 @@ enum ipu7_insys_resp_type { @@ -64,33 +60,15 @@ index 45db85eb13..171b69c8c8 100644 #pragma pack(push, 1) struct ipu7_insys_resolution { u32 width; -@@ -349,6 +352,26 @@ struct ipu7_insys_buffset { +@@ -312,7 +315,7 @@ struct ipu7_insys_resp { + u8 pin_id; + u8 frame_id; + u8 skip_frame; +- u8 pad[2]; ++ u16 mipi_fn; }; - struct ipu7_insys_resp { -+ u64 buf_id; -+ struct ipu7_insys_capture_output_pin_payload pin; -+ struct ia_gofo_msg_err error_info; -+ u32 timestamp[2]; -+ u16 mipi_fn; -+ u8 type; -+ u8 msg_link_streaming_mode; -+ u8 stream_id; -+ u8 pin_id; -+ u8 frame_id; -+ u8 skip_frame; -+}; -+ -+/** -+ * TODO: Revert this change after firmware ABI fixed. -+ * This is an internal workaround. -+ * IPU7.5 firmware changed its ABI and breaks -+ * compatibility with IPU7 Lunar Lake. -+ */ -+struct ipu7_insys_legacy_resp { - u64 buf_id; - struct ipu7_insys_capture_output_pin_payload pin; - struct ia_gofo_msg_err error_info; + struct ipu7_insys_resp_queue_token { diff --git a/drivers/staging/media/ipu7/abi/ipu7_fw_msg_abi.h b/drivers/staging/media/ipu7/abi/ipu7_fw_msg_abi.h index 8a78dd0936..1319f0eb63 100644 --- a/drivers/staging/media/ipu7/abi/ipu7_fw_msg_abi.h @@ -104,42 +82,6 @@ index 8a78dd0936..1319f0eb63 100644 ipu7_msg_teb_t payload_reuse_bm; ia_gofo_addr_t term_buffers[IPU_MSG_MAX_NODE_TERMS]; }; -diff --git a/drivers/staging/media/ipu7/ipu7-fw-isys.c b/drivers/staging/media/ipu7/ipu7-fw-isys.c -index 2958e39a35..26704c6fad 100644 ---- a/drivers/staging/media/ipu7/ipu7-fw-isys.c -+++ b/drivers/staging/media/ipu7/ipu7-fw-isys.c -@@ -195,9 +195,30 @@ int ipu7_fw_isys_close(struct ipu7_isys *isys) - - struct ipu7_insys_resp *ipu7_fw_isys_get_resp(struct ipu7_isys *isys) - { -- return (struct ipu7_insys_resp *) -+ /** -+ * TODO: Revert this change after firmware ABI fixed. -+ * This is an internal workaround. -+ * IPU7.5 firmware changed its ABI and breaks -+ * compatibility with IPU7 Lunar Lake. -+ */ -+ struct ipu7_insys_resp *resp = - ipu7_syscom_get_token(isys->adev->syscom, - IPU_INSYS_OUTPUT_MSG_QUEUE); -+ -+ if (resp && isys->adev->isp->hw_ver == IPU_VER_7) { -+ struct ipu7_insys_legacy_resp lnl_resp; -+ -+ memcpy(&lnl_resp, resp, sizeof(struct ipu7_insys_resp)); -+ resp->mipi_fn = 0; -+ resp->type = lnl_resp.type; -+ resp->msg_link_streaming_mode = lnl_resp.msg_link_streaming_mode; -+ resp->stream_id = lnl_resp.stream_id; -+ resp->pin_id = lnl_resp.pin_id; -+ resp->frame_id = lnl_resp.frame_id; -+ resp->skip_frame = lnl_resp.skip_frame; -+ } -+ -+ return resp; - } - - void ipu7_fw_isys_put_resp(struct ipu7_isys *isys) -- 2.43.0 diff --git a/patch/v6.17_iot/0021-media-ipu7-update-CDPHY-register-settings.patch b/patch/v6.17_iot/0021-media-ipu7-update-CDPHY-register-settings.patch new file mode 100644 index 0000000..91fac52 --- /dev/null +++ b/patch/v6.17_iot/0021-media-ipu7-update-CDPHY-register-settings.patch @@ -0,0 +1,80 @@ +From 0db4964475bb43eeff1bff6bf6c00fa5a29ba561 Mon Sep 17 00:00:00 2001 +From: hepengpx +Date: Fri, 19 Dec 2025 15:29:00 +0800 +Subject: [PATCH] media: ipu7: update CDPHY register settings + +Some CPHY settings are copied from Wins code, but some of +them aren't correct and need to be fixed. + +Program 45ohm for tuning resistance to fix CPHY problem and +update the ITMINRX and GMODE for CPHY high data rate. + +Test Platform: +PTLRVP +LNLRVP + +Signed-off-by: Bingbu Cao +--- + drivers/staging/media/ipu7/ipu7-isys-csi-phy.c | 15 +++++++++++---- + 1 file changed, 11 insertions(+), 4 deletions(-) + +diff --git a/drivers/staging/media/ipu7/ipu7-isys-csi-phy.c b/drivers/staging/media/ipu7/ipu7-isys-csi-phy.c +index b8c5db7ae..97cd47daf 100644 +--- a/drivers/staging/media/ipu7/ipu7-isys-csi-phy.c ++++ b/drivers/staging/media/ipu7/ipu7-isys-csi-phy.c +@@ -124,6 +124,7 @@ static const struct cdr_fbk_cap_prog_params table7[] = { + { 1350, 1589, 4 }, + { 1590, 1949, 5 }, + { 1950, 2499, 6 }, ++ { 2500, 3500, 7 }, + { } + }; + +@@ -730,7 +731,7 @@ static void ipu7_isys_cphy_config(struct ipu7_isys *isys, u8 id, u8 lanes, + u16 deass_thresh; + u16 delay_thresh; + u16 reset_thresh; +- u16 cap_prog = 6U; ++ u16 cap_prog; + u16 reg; + u16 val; + u32 i; +@@ -838,9 +839,10 @@ static void ipu7_isys_cphy_config(struct ipu7_isys *isys, u8 id, u8 lanes, + dwc_phy_write_mask(isys, id, reg + 0x400 * i, + reset_thresh, 9, 11); + ++ /* Tuning ITMINRX to 2 for CPHY */ + reg = CORE_DIG_CLANE_0_RW_LP_0; + for (i = 0; i < trios; i++) +- dwc_phy_write_mask(isys, id, reg + 0x400 * i, 1, 12, 15); ++ dwc_phy_write_mask(isys, id, reg + 0x400 * i, 2, 12, 15); + + reg = CORE_DIG_CLANE_0_RW_LP_2; + for (i = 0; i < trios; i++) +@@ -860,7 +862,11 @@ static void ipu7_isys_cphy_config(struct ipu7_isys *isys, u8 id, u8 lanes, + for (i = 0; i < (lanes + 1); i++) { + reg = CORE_DIG_IOCTRL_RW_AFE_LANE0_CTRL_2_9 + 0x400 * i; + dwc_phy_write_mask(isys, id, reg, 4U, 0, 2); +- dwc_phy_write_mask(isys, id, reg, 0U, 3, 4); ++ /* Set GMODE to 2 when CPHY >= 1.5Gsps */ ++ if (mbps >= 1500) ++ dwc_phy_write_mask(isys, id, reg, 2U, 3, 4); ++ else ++ dwc_phy_write_mask(isys, id, reg, 0U, 3, 4); + + reg = CORE_DIG_IOCTRL_RW_AFE_LANE0_CTRL_2_7 + 0x400 * i; + dwc_phy_write_mask(isys, id, reg, cap_prog, 10, 12); +@@ -930,8 +936,9 @@ static int ipu7_isys_phy_config(struct ipu7_isys *isys, u8 id, u8 lanes, + 7, 12, 14); + dwc_phy_write_mask(isys, id, CORE_DIG_IOCTRL_RW_AFE_CB_CTRL_2_7, + 0, 8, 10); ++ /* resistance tuning: 1 for 45ohm, 0 for 50ohm */ + dwc_phy_write_mask(isys, id, CORE_DIG_IOCTRL_RW_AFE_CB_CTRL_2_5, +- 0, 8, 8); ++ 1, 8, 8); + + if (aggregation) + phy_mode = isys->csi2[0].phy_mode; +-- +2.34.1 +