openwrt/target/linux/ramips/patches-5.15/110-reset_controller_driver.patch

62 lines
1.5 KiB
Diff
Raw Normal View History

--- a/arch/mips/ralink/reset.c
+++ b/arch/mips/ralink/reset.c
@@ -11,6 +11,7 @@
#include <linux/of.h>
#include <linux/delay.h>
#include <linux/reset-controller.h>
+#include <linux/platform_device.h>
#include <asm/reboot.h>
@@ -65,21 +66,39 @@ static const struct reset_control_ops re
.deassert = ralink_deassert_device,
};
-static struct reset_controller_dev reset_dev = {
- .ops = &reset_ops,
- .owner = THIS_MODULE,
- .nr_resets = 32,
- .of_reset_n_cells = 1,
+static int ralink_reset_probe(struct platform_device *pdev)
+{
+ struct reset_controller_dev *rcdev;
+
+ rcdev = devm_kzalloc(&pdev->dev, sizeof(*rcdev), GFP_KERNEL);
+ if (!rcdev)
+ return -ENOMEM;
+
+ rcdev->ops = &reset_ops;
+ rcdev->owner = THIS_MODULE;
+ rcdev->nr_resets = 32;
+ rcdev->of_reset_n_cells = 1;
+ rcdev->of_node = pdev->dev.of_node;
+
+ return devm_reset_controller_register(&pdev->dev, rcdev);
+}
+
+static const struct of_device_id ralink_reset_dt_ids[] = {
+ { .compatible = "ralink,rt2880-reset" },
+ {}
+};
+
+static struct platform_driver ralink_reset_driver = {
+ .probe = ralink_reset_probe,
+ .driver = {
+ .name = "ralink-reset",
+ .of_match_table = ralink_reset_dt_ids,
+ }
};
void ralink_rst_init(void)
{
- reset_dev.of_node = of_find_compatible_node(NULL, NULL,
- "ralink,rt2880-reset");
- if (!reset_dev.of_node)
- pr_err("Failed to find reset controller node");
- else
- reset_controller_register(&reset_dev);
+ platform_driver_register(&ralink_reset_driver);
}
static void ralink_restart(char *command)