6c923d70c3bca1fd4ccd9fa9f4f9b9969ec2a1c3
[openwrt/staging/stintel.git] / target / linux / ramips / patches-5.15 / 110-reset_controller_driver.patch
1 --- a/arch/mips/ralink/reset.c
2 +++ b/arch/mips/ralink/reset.c
3 @@ -11,6 +11,7 @@
4 #include <linux/of.h>
5 #include <linux/delay.h>
6 #include <linux/reset-controller.h>
7 +#include <linux/platform_device.h>
8
9 #include <asm/reboot.h>
10
11 @@ -65,21 +66,39 @@ static const struct reset_control_ops re
12 .deassert = ralink_deassert_device,
13 };
14
15 -static struct reset_controller_dev reset_dev = {
16 - .ops = &reset_ops,
17 - .owner = THIS_MODULE,
18 - .nr_resets = 32,
19 - .of_reset_n_cells = 1,
20 +static int ralink_reset_probe(struct platform_device *pdev)
21 +{
22 + struct reset_controller_dev *rcdev;
23 +
24 + rcdev = devm_kzalloc(&pdev->dev, sizeof(*rcdev), GFP_KERNEL);
25 + if (!rcdev)
26 + return -ENOMEM;
27 +
28 + rcdev->ops = &reset_ops;
29 + rcdev->owner = THIS_MODULE;
30 + rcdev->nr_resets = 32;
31 + rcdev->of_reset_n_cells = 1;
32 + rcdev->of_node = pdev->dev.of_node;
33 +
34 + return devm_reset_controller_register(&pdev->dev, rcdev);
35 +}
36 +
37 +static const struct of_device_id ralink_reset_dt_ids[] = {
38 + { .compatible = "ralink,rt2880-reset" },
39 + {}
40 +};
41 +
42 +static struct platform_driver ralink_reset_driver = {
43 + .probe = ralink_reset_probe,
44 + .driver = {
45 + .name = "ralink-reset",
46 + .of_match_table = ralink_reset_dt_ids,
47 + }
48 };
49
50 void ralink_rst_init(void)
51 {
52 - reset_dev.of_node = of_find_compatible_node(NULL, NULL,
53 - "ralink,rt2880-reset");
54 - if (!reset_dev.of_node)
55 - pr_err("Failed to find reset controller node");
56 - else
57 - reset_controller_register(&reset_dev);
58 + platform_driver_register(&ralink_reset_driver);
59 }
60
61 static void ralink_restart(char *command)