hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/media/platform/rockchip/cif/hw.c
....@@ -8,6 +8,7 @@
88 #include <linux/delay.h>
99 #include <linux/interrupt.h>
1010 #include <linux/module.h>
11
+#include <linux/nvmem-consumer.h>
1112 #include <linux/of.h>
1213 #include <linux/of_gpio.h>
1314 #include <linux/of_graph.h>
....@@ -1252,6 +1253,51 @@
12521253 rkcif_iommu_enable(cif_hw);
12531254 }
12541255
1256
+static int rkcif_get_efuse_value(struct device_node *np, char *porp_name,
1257
+ u8 *value)
1258
+{
1259
+ struct nvmem_cell *cell;
1260
+ unsigned char *buf;
1261
+ size_t len;
1262
+
1263
+ cell = of_nvmem_cell_get(np, porp_name);
1264
+ if (IS_ERR(cell))
1265
+ return PTR_ERR(cell);
1266
+
1267
+ buf = (unsigned char *)nvmem_cell_read(cell, &len);
1268
+
1269
+ nvmem_cell_put(cell);
1270
+
1271
+ if (IS_ERR(buf))
1272
+ return PTR_ERR(buf);
1273
+
1274
+ *value = buf[0];
1275
+
1276
+ kfree(buf);
1277
+
1278
+ return 0;
1279
+}
1280
+
1281
+static int rkcif_get_speciand_package_number(struct device_node *np)
1282
+{
1283
+ u8 spec = 0, package = 0, low = 0, high = 0;
1284
+
1285
+ if (rkcif_get_efuse_value(np, "specification", &spec))
1286
+ return -EINVAL;
1287
+ if (rkcif_get_efuse_value(np, "package_low", &low))
1288
+ return -EINVAL;
1289
+ if (rkcif_get_efuse_value(np, "package_high", &high))
1290
+ return -EINVAL;
1291
+
1292
+ package = ((high & 0x1) << 3) | low;
1293
+
1294
+ /* RK3588S */
1295
+ if (spec == 0x13)
1296
+ return package;
1297
+
1298
+ return -EINVAL;
1299
+}
1300
+
12551301 static int rkcif_plat_hw_probe(struct platform_device *pdev)
12561302 {
12571303 const struct of_device_id *match;
....@@ -1265,6 +1311,7 @@
12651311 int i, ret, irq;
12661312 bool is_mem_reserved = false;
12671313 struct notifier_block *notifier;
1314
+ int package = 0;
12681315
12691316 match = of_match_node(rkcif_plat_of_match, node);
12701317 if (IS_ERR(match))
....@@ -1278,6 +1325,13 @@
12781325 dev_set_drvdata(dev, cif_hw);
12791326 cif_hw->dev = dev;
12801327
1328
+ package = rkcif_get_speciand_package_number(node);
1329
+ if (package == 0x2) {
1330
+ cif_hw->is_rk3588s2 = true;
1331
+ dev_info(dev, "attach rk3588s2\n");
1332
+ } else {
1333
+ cif_hw->is_rk3588s2 = false;
1334
+ }
12811335 irq = platform_get_irq(pdev, 0);
12821336 if (irq < 0)
12831337 return irq;
....@@ -1506,6 +1560,7 @@
15061560 ret = platform_driver_register(&rkcif_hw_plat_drv);
15071561 if (ret)
15081562 return ret;
1563
+ rkcif_csi2_hw_plat_drv_init();
15091564 return rkcif_csi2_plat_drv_init();
15101565 }
15111566
....@@ -1513,6 +1568,7 @@
15131568 {
15141569 platform_driver_unregister(&rkcif_hw_plat_drv);
15151570 rkcif_csi2_plat_drv_exit();
1571
+ rkcif_csi2_hw_plat_drv_exit();
15161572 }
15171573
15181574 #if defined(CONFIG_VIDEO_ROCKCHIP_THUNDER_BOOT_ISP) && !defined(CONFIG_INITCALL_ASYNC)