Merge branch 'CR_1446_v4l2_syscon_changhuang.liang' into 'jh7110-5.15.y-devel'
authorandy.hu <andy.hu@starfivetech.com>
Thu, 30 Jun 2022 10:41:31 +0000 (10:41 +0000)
committerandy.hu <andy.hu@starfivetech.com>
Thu, 30 Jun 2022 10:41:31 +0000 (10:41 +0000)
V4L2: modify syscon interface

See merge request sdk/linux!208

arch/riscv/boot/dts/starfive/jh7110.dtsi
drivers/media/platform/starfive/v4l2_driver/stf_csi_hw_ops.c
drivers/media/platform/starfive/v4l2_driver/stfcamss.c
drivers/media/platform/starfive/v4l2_driver/stfcamss.h

index 518f58a..dcbe71c 100755 (executable)
                                "rst_m31dphy_hw", "rst_m31dphy_b09_always_on",
                                "rst_isp_top_n", "rst_isp_top_axi";
                        interrupts = <92 87>;
+                       starfive,aon-syscon = <&aon_syscon 0x00>;
                        status = "disabled";
                };
 
index 5586846..ea0274c 100755 (executable)
@@ -38,7 +38,7 @@
 
 static int stf_csi_power_on(struct stf_csi_dev *csi_dev, u8 on)
 {
-       void __iomem *aon_syscon;
+       struct stfcamss *stfcamss = csi_dev->stfcamss;
        int ret;
 
        if (on) {
@@ -58,8 +58,7 @@ static int stf_csi_power_on(struct stf_csi_dev *csi_dev, u8 on)
                regulator_disable(csi_dev->mipirx_0p9);
        }
 
-       aon_syscon = ioremap(0x17010000, 0x4);
-       reg_write(aon_syscon, 0x00, 0x80000000);
+       regmap_write(stfcamss->stf_aon_syscon, stfcamss->aon_gp_reg, 0x80000000);
 
        return 0;
 
index bdf1c5b..5f4dd4d 100755 (executable)
@@ -20,6 +20,7 @@
 #include <linux/io.h>
 #include <linux/dma-mapping.h>
 #include <linux/uaccess.h>
+#include <linux/mfd/syscon.h>
 
 #include <linux/videodev2.h>
 
@@ -958,6 +959,7 @@ static int stfcamss_probe(struct platform_device *pdev)
        struct stfcamss *stfcamss;
        struct stf_vin_dev *vin;
        struct device *dev = &pdev->dev;
+       struct of_phandle_args args;
        int ret = 0, num_subdevs;
 
        dev_info(dev, "stfcamss probe enter!\n");
@@ -1062,6 +1064,20 @@ static int stfcamss_probe(struct platform_device *pdev)
                return ret;
        }
 
+       ret = of_parse_phandle_with_fixed_args(dev->of_node,
+                       "starfive,aon-syscon", 1, 0, &args);
+       if (ret < 0) {
+               dev_err(dev, "Failed to parse starfive,aon-syscon\n");
+               return -EINVAL;
+       }
+
+       stfcamss->stf_aon_syscon = syscon_node_to_regmap(args.np);
+       of_node_put(args.np);
+       if (IS_ERR(stfcamss->stf_aon_syscon))
+               return PTR_ERR(stfcamss->stf_aon_syscon);
+
+       stfcamss->aon_gp_reg = args.args[0];
+
        ret = stfcamss_get_mem_res(pdev, vin);
        if (ret) {
                st_err(ST_CAMSS, "Could not map registers\n");
index 21cc414..095d210 100755 (executable)
@@ -98,6 +98,8 @@ struct stfcamss {
        int nclks;
        struct reset_control_bulk_data *sys_rst;
        int nrsts;
+       struct regmap *stf_aon_syscon;
+       uint32_t aon_gp_reg;
 #ifdef CONFIG_DEBUG_FS
        struct dentry *debugfs_entry;
        struct dentry *vin_debugfs;