hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/media/platform/rockchip/cif/dev.c
....@@ -20,7 +20,6 @@
2020 #include <media/videobuf2-dma-contig.h>
2121 #include <media/v4l2-fwnode.h>
2222 #include <linux/iommu.h>
23
-#include <dt-bindings/soc/rockchip-system-status.h>
2423 #include <soc/rockchip/rockchip-system-status.h>
2524 #include <linux/io.h>
2625 #include <linux/mfd/syscon.h>
....@@ -1134,6 +1133,7 @@
11341133 cif_dev->reset_watchdog_timer.is_triggered = false;
11351134 cif_dev->reset_watchdog_timer.is_running = false;
11361135 cif_dev->err_state_work.last_timestamp = 0;
1136
+ cif_dev->is_toisp_reset = false;
11371137 for (i = 0; i < cif_dev->num_channels; i++)
11381138 cif_dev->reset_watchdog_timer.last_buf_wakeup_cnt[i] = 0;
11391139 cif_dev->reset_watchdog_timer.run_cnt = 0;
....@@ -1218,6 +1218,7 @@
12181218 cif_dev->is_start_hdr = true;
12191219 cif_dev->reset_watchdog_timer.is_triggered = false;
12201220 cif_dev->reset_watchdog_timer.is_running = false;
1221
+ cif_dev->is_toisp_reset = false;
12211222 for (i = 0; i < cif_dev->num_channels; i++)
12221223 cif_dev->reset_watchdog_timer.last_buf_wakeup_cnt[i] = 0;
12231224 cif_dev->reset_watchdog_timer.run_cnt = 0;
....@@ -1908,6 +1909,32 @@
19081909 INIT_WORK(&dev->reset_work.work, rkcif_reset_work);
19091910 }
19101911
1912
+void rkcif_set_sensor_stream(struct work_struct *work)
1913
+{
1914
+ struct rkcif_sensor_work *sensor_work = container_of(work,
1915
+ struct rkcif_sensor_work,
1916
+ work);
1917
+ struct rkcif_device *cif_dev = container_of(sensor_work,
1918
+ struct rkcif_device,
1919
+ sensor_work);
1920
+
1921
+ v4l2_subdev_call(cif_dev->terminal_sensor.sd,
1922
+ core, ioctl,
1923
+ RKMODULE_SET_QUICK_STREAM,
1924
+ &sensor_work->on);
1925
+}
1926
+
1927
+static void rkcif_deal_err_intr(struct work_struct *work)
1928
+{
1929
+ struct delayed_work *dwork = to_delayed_work(work);
1930
+ struct rkcif_device *cif_dev = container_of(dwork,
1931
+ struct rkcif_device,
1932
+ work_deal_err);
1933
+
1934
+ cif_dev->intr_mask |= CSI_BANDWIDTH_LACK_V1;
1935
+ rkcif_write_register_or(cif_dev, CIF_REG_MIPI_LVDS_INTEN, CSI_BANDWIDTH_LACK_V1);
1936
+}
1937
+
19111938 int rkcif_plat_init(struct rkcif_device *cif_dev, struct device_node *node, int inf_id)
19121939 {
19131940 struct device *dev = cif_dev->dev;
....@@ -1927,6 +1954,7 @@
19271954 atomic_set(&cif_dev->pipe.power_cnt, 0);
19281955 atomic_set(&cif_dev->pipe.stream_cnt, 0);
19291956 atomic_set(&cif_dev->power_cnt, 0);
1957
+ atomic_set(&cif_dev->streamoff_cnt, 0);
19301958 cif_dev->is_start_hdr = false;
19311959 cif_dev->pipe.open = rkcif_pipeline_open;
19321960 cif_dev->pipe.close = rkcif_pipeline_close;
....@@ -1940,11 +1968,15 @@
19401968 cif_dev->early_line = 0;
19411969 cif_dev->is_thunderboot = false;
19421970 cif_dev->rdbk_debug = 0;
1971
+
1972
+ cif_dev->resume_mode = 0;
19431973 memset(&cif_dev->channels[0].capture_info, 0, sizeof(cif_dev->channels[0].capture_info));
19441974 if (cif_dev->chip_id == CHIP_RV1126_CIF_LITE)
19451975 cif_dev->isr_hdl = rkcif_irq_lite_handler;
19461976
19471977 INIT_WORK(&cif_dev->err_state_work.work, rkcif_err_print_work);
1978
+ INIT_WORK(&cif_dev->sensor_work.work, rkcif_set_sensor_stream);
1979
+ INIT_DELAYED_WORK(&cif_dev->work_deal_err, rkcif_deal_err_intr);
19481980
19491981 if (cif_dev->chip_id < CHIP_RV1126_CIF) {
19501982 if (cif_dev->inf_id == RKCIF_MIPI_LVDS) {
....@@ -2118,6 +2150,8 @@
21182150 struct resource r;
21192151 int ret;
21202152
2153
+ cif_dev->is_thunderboot = false;
2154
+ cif_dev->is_rtt_suspend = false;
21212155 /* Get reserved memory region from Device-tree */
21222156 np = of_parse_phandle(dev->of_node, "memory-region-thunderboot", 0);
21232157 if (!np) {
....@@ -2133,7 +2167,14 @@
21332167
21342168 cif_dev->resmem_pa = r.start;
21352169 cif_dev->resmem_size = resource_size(&r);
2136
- cif_dev->is_thunderboot = true;
2170
+ cif_dev->resmem_addr = dma_map_single(dev, phys_to_virt(r.start),
2171
+ sizeof(struct rkisp_thunderboot_resmem_head),
2172
+ DMA_BIDIRECTIONAL);
2173
+
2174
+ if (device_property_read_bool(dev, "rtt-suspend"))
2175
+ cif_dev->is_rtt_suspend = true;
2176
+ if (IS_ENABLED(CONFIG_VIDEO_ROCKCHIP_THUNDER_BOOT_ISP))
2177
+ cif_dev->is_thunderboot = true;
21372178 dev_info(dev, "Allocated reserved memory, paddr: 0x%x, size 0x%x\n",
21382179 (u32)cif_dev->resmem_pa,
21392180 (u32)cif_dev->resmem_size);
....@@ -2211,6 +2252,22 @@
22112252 return 0;
22122253 }
22132254
2255
+static int __maybe_unused rkcif_sleep_suspend(struct device *dev)
2256
+{
2257
+ struct rkcif_device *cif_dev = dev_get_drvdata(dev);
2258
+
2259
+ rkcif_stream_suspend(cif_dev, RKCIF_RESUME_CIF);
2260
+ return 0;
2261
+}
2262
+
2263
+static int __maybe_unused rkcif_sleep_resume(struct device *dev)
2264
+{
2265
+ struct rkcif_device *cif_dev = dev_get_drvdata(dev);
2266
+
2267
+ rkcif_stream_resume(cif_dev, RKCIF_RESUME_CIF);
2268
+ return 0;
2269
+}
2270
+
22142271 static int __maybe_unused rkcif_runtime_suspend(struct device *dev)
22152272 {
22162273 struct rkcif_device *cif_dev = dev_get_drvdata(dev);
....@@ -2281,8 +2338,7 @@
22812338 #endif
22822339
22832340 static const struct dev_pm_ops rkcif_plat_pm_ops = {
2284
- SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
2285
- pm_runtime_force_resume)
2341
+ SET_SYSTEM_SLEEP_PM_OPS(rkcif_sleep_suspend, rkcif_sleep_resume)
22862342 SET_RUNTIME_PM_OPS(rkcif_runtime_suspend, rkcif_runtime_resume, NULL)
22872343 };
22882344