.. | .. |
---|
8 | 8 | #include <linux/delay.h> |
---|
9 | 9 | #include <linux/interrupt.h> |
---|
10 | 10 | #include <linux/module.h> |
---|
| 11 | +#include <linux/nvmem-consumer.h> |
---|
11 | 12 | #include <linux/of.h> |
---|
12 | 13 | #include <linux/of_gpio.h> |
---|
13 | 14 | #include <linux/of_graph.h> |
---|
.. | .. |
---|
1252 | 1253 | rkcif_iommu_enable(cif_hw); |
---|
1253 | 1254 | } |
---|
1254 | 1255 | |
---|
| 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 | + |
---|
1255 | 1301 | static int rkcif_plat_hw_probe(struct platform_device *pdev) |
---|
1256 | 1302 | { |
---|
1257 | 1303 | const struct of_device_id *match; |
---|
.. | .. |
---|
1265 | 1311 | int i, ret, irq; |
---|
1266 | 1312 | bool is_mem_reserved = false; |
---|
1267 | 1313 | struct notifier_block *notifier; |
---|
| 1314 | + int package = 0; |
---|
1268 | 1315 | |
---|
1269 | 1316 | match = of_match_node(rkcif_plat_of_match, node); |
---|
1270 | 1317 | if (IS_ERR(match)) |
---|
.. | .. |
---|
1278 | 1325 | dev_set_drvdata(dev, cif_hw); |
---|
1279 | 1326 | cif_hw->dev = dev; |
---|
1280 | 1327 | |
---|
| 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 | + } |
---|
1281 | 1335 | irq = platform_get_irq(pdev, 0); |
---|
1282 | 1336 | if (irq < 0) |
---|
1283 | 1337 | return irq; |
---|
.. | .. |
---|
1506 | 1560 | ret = platform_driver_register(&rkcif_hw_plat_drv); |
---|
1507 | 1561 | if (ret) |
---|
1508 | 1562 | return ret; |
---|
| 1563 | + rkcif_csi2_hw_plat_drv_init(); |
---|
1509 | 1564 | return rkcif_csi2_plat_drv_init(); |
---|
1510 | 1565 | } |
---|
1511 | 1566 | |
---|
.. | .. |
---|
1513 | 1568 | { |
---|
1514 | 1569 | platform_driver_unregister(&rkcif_hw_plat_drv); |
---|
1515 | 1570 | rkcif_csi2_plat_drv_exit(); |
---|
| 1571 | + rkcif_csi2_hw_plat_drv_exit(); |
---|
1516 | 1572 | } |
---|
1517 | 1573 | |
---|
1518 | 1574 | #if defined(CONFIG_VIDEO_ROCKCHIP_THUNDER_BOOT_ISP) && !defined(CONFIG_INITCALL_ASYNC) |
---|