2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
10 #include <linux/module.h>
12 #include <linux/platform_device.h>
13 #include <linux/reset-controller.h>
14 #include <linux/slab.h>
15 #include <linux/types.h>
16 #include <mach/hardware.h>
18 static int ox820_reset_reset(struct reset_controller_dev
*rcdev
,
21 writel(BIT(id
), SYS_CTRL_RST_SET_CTRL
);
22 writel(BIT(id
), SYS_CTRL_RST_CLR_CTRL
);
26 static int ox820_reset_assert(struct reset_controller_dev
*rcdev
,
29 writel(BIT(id
), SYS_CTRL_RST_SET_CTRL
);
34 static int ox820_reset_deassert(struct reset_controller_dev
*rcdev
,
37 writel(BIT(id
), SYS_CTRL_RST_CLR_CTRL
);
42 static struct reset_control_ops ox820_reset_ops
= {
43 .reset
= ox820_reset_reset
,
44 .assert = ox820_reset_assert
,
45 .deassert
= ox820_reset_deassert
,
48 static const struct of_device_id ox820_reset_dt_ids
[] = {
49 { .compatible
= "plxtech,nas782x-reset", },
52 MODULE_DEVICE_TABLE(of
, ox820_reset_dt_ids
);
54 struct reset_controller_dev rcdev
;
56 static int ox820_reset_probe(struct platform_device
*pdev
)
58 struct reset_controller_dev
*rcdev
;
60 rcdev
= devm_kzalloc(&pdev
->dev
, sizeof(*rcdev
), GFP_KERNEL
);
64 /* note: reset controller is statically mapped */
66 rcdev
->owner
= THIS_MODULE
;
67 rcdev
->nr_resets
= 32;
68 rcdev
->ops
= &ox820_reset_ops
;
69 rcdev
->of_node
= pdev
->dev
.of_node
;
70 reset_controller_register(rcdev
);
71 platform_set_drvdata(pdev
, rcdev
);
76 static int ox820_reset_remove(struct platform_device
*pdev
)
78 struct reset_controller_dev
*rcdev
= platform_get_drvdata(pdev
);
80 reset_controller_unregister(rcdev
);
85 static struct platform_driver ox820_reset_driver
= {
86 .probe
= ox820_reset_probe
,
87 .remove
= ox820_reset_remove
,
89 .name
= "ox820-reset",
91 .of_match_table
= ox820_reset_dt_ids
,
95 static int __init
ox820_reset_init(void)
97 return platform_driver_probe(&ox820_reset_driver
,
101 * reset controller does not support probe deferral, so it has to be
102 * initialized before any user, in particular, PCIE uses subsys_initcall.
104 arch_initcall(ox820_reset_init
);
106 MODULE_AUTHOR("Ma Haijun");
107 MODULE_LICENSE("GPL");