forked from coolsnowwolf/lede
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rockchip: fix kernel 6.1 patch for dfi
- Loading branch information
1 parent
3f6bb72
commit 65d8795
Showing
1 changed file
with
104 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -444,7 +444,8 @@ Signed-off-by: hmz007 <[email protected]> | |
+ struct device_node *np = pdev->dev.of_node, *node; | ||
+ struct resource *res; | ||
+ u32 val; | ||
+ | ||
|
||
-static int rockchip_dfi_probe(struct platform_device *pdev) | ||
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
+ data->regs = devm_ioremap_resource(&pdev->dev, res); | ||
+ if (IS_ERR(data->regs)) | ||
|
@@ -466,8 +467,7 @@ Signed-off-by: hmz007 <[email protected]> | |
+ | ||
+ return 0; | ||
+} | ||
|
||
-static int rockchip_dfi_probe(struct platform_device *pdev) | ||
+ | ||
+static __init int rk3128_dfi_init(struct platform_device *pdev, | ||
+ struct rockchip_dfi *data, | ||
+ struct devfreq_event_desc *desc) | ||
|
@@ -557,3 +557,104 @@ Signed-off-by: hmz007 <[email protected]> | |
|
||
data->regs = devm_platform_ioremap_resource(pdev, 0); | ||
if (IS_ERR(data->regs)) | ||
@@ -202,21 +202,95 @@ static int rockchip_dfi_probe(struct pla | ||
if (IS_ERR(data->regmap_pmu)) | ||
return PTR_ERR(data->regmap_pmu); | ||
|
||
- data->dev = dev; | ||
+ regmap_read(data->regmap_pmu, PMUGRF_OS_REG2, &val); | ||
+ data->dram_type = READ_DRAMTYPE_INFO(val); | ||
+ data->ch_msk = READ_CH_INFO(val); | ||
+ | ||
+ desc->ops = &rockchip_dfi_ops; | ||
+ | ||
+ return 0; | ||
+} | ||
+ | ||
+static __init int rk3328_dfi_init(struct platform_device *pdev, | ||
+ struct rockchip_dfi *data, | ||
+ struct devfreq_event_desc *desc) | ||
+{ | ||
+ struct device_node *np = pdev->dev.of_node, *node; | ||
+ struct resource *res; | ||
+ u32 val; | ||
+ | ||
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
+ data->regs = devm_ioremap_resource(&pdev->dev, res); | ||
+ if (IS_ERR(data->regs)) | ||
+ return PTR_ERR(data->regs); | ||
+ | ||
+ node = of_parse_phandle(np, "rockchip,grf", 0); | ||
+ if (node) { | ||
+ data->regmap_grf = syscon_node_to_regmap(node); | ||
+ if (IS_ERR(data->regmap_grf)) | ||
+ return PTR_ERR(data->regmap_grf); | ||
+ } | ||
+ | ||
+ regmap_read(data->regmap_grf, RK3328_GRF_OS_REG2, &val); | ||
+ data->dram_type = READ_DRAMTYPE_INFO(val); | ||
+ data->ch_msk = 1; | ||
+ data->clk = NULL; | ||
+ | ||
+ desc->ops = &rockchip_dfi_ops; | ||
+ | ||
+ return 0; | ||
+} | ||
+ | ||
+static const struct of_device_id rockchip_dfi_id_match[] = { | ||
+ { .compatible = "rockchip,px30-dfi", .data = px30_dfi_init }, | ||
+ { .compatible = "rockchip,rk1808-dfi", .data = px30_dfi_init }, | ||
+ { .compatible = "rockchip,rk3128-dfi", .data = rk3128_dfi_init }, | ||
+ { .compatible = "rockchip,rk3288-dfi", .data = rk3288_dfi_init }, | ||
+ { .compatible = "rockchip,rk3328-dfi", .data = rk3328_dfi_init }, | ||
+ { .compatible = "rockchip,rk3368-dfi", .data = rk3368_dfi_init }, | ||
+ { .compatible = "rockchip,rk3399-dfi", .data = rockchip_dfi_init }, | ||
+ { }, | ||
+}; | ||
+MODULE_DEVICE_TABLE(of, rockchip_dfi_id_match); | ||
+ | ||
+static int rockchip_dfi_probe(struct platform_device *pdev) | ||
+{ | ||
+ struct device *dev = &pdev->dev; | ||
+ struct rockchip_dfi *data; | ||
+ struct devfreq_event_desc *desc; | ||
+ struct device_node *np = pdev->dev.of_node; | ||
+ const struct of_device_id *match; | ||
+ int (*init)(struct platform_device *pdev, struct rockchip_dfi *data, | ||
+ struct devfreq_event_desc *desc); | ||
+ | ||
+ data = devm_kzalloc(dev, sizeof(struct rockchip_dfi), GFP_KERNEL); | ||
+ if (!data) | ||
+ return -ENOMEM; | ||
|
||
desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL); | ||
if (!desc) | ||
return -ENOMEM; | ||
|
||
- desc->ops = &rockchip_dfi_ops; | ||
+ match = of_match_node(rockchip_dfi_id_match, pdev->dev.of_node); | ||
+ if (match) { | ||
+ init = match->data; | ||
+ if (init) { | ||
+ if (init(pdev, data, desc)) | ||
+ return -EINVAL; | ||
+ } else { | ||
+ return 0; | ||
+ } | ||
+ } else { | ||
+ return 0; | ||
+ } | ||
desc->driver_data = data; | ||
desc->name = np->name; | ||
data->desc = desc; | ||
+ data->dev = dev; | ||
|
||
- data->edev = devm_devfreq_event_add_edev(&pdev->dev, desc); | ||
+ data->edev = devm_devfreq_event_add_edev(dev, desc); | ||
if (IS_ERR(data->edev)) { | ||
- dev_err(&pdev->dev, | ||
- "failed to add devfreq-event device\n"); | ||
+ dev_err(dev, "failed to add devfreq-event device\n"); | ||
return PTR_ERR(data->edev); | ||
} | ||
|