1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Allwinner SoCs Reset Controller driver
5 * Copyright 2013 Maxime Ripard
7 * Maxime Ripard <maxime.ripard@free-electrons.com>
10 #include <linux/err.h>
12 #include <linux/init.h>
14 #include <linux/of_address.h>
15 #include <linux/platform_device.h>
16 #include <linux/reset-controller.h>
17 #include <linux/reset/sunxi.h>
18 #include <linux/slab.h>
19 #include <linux/spinlock.h>
20 #include <linux/types.h>
22 #include "reset-simple.h"
24 static int sunxi_reset_init(struct device_node
*np
)
26 struct reset_simple_data
*data
;
31 data
= kzalloc(sizeof(*data
), GFP_KERNEL
);
35 ret
= of_address_to_resource(np
, 0, &res
);
39 size
= resource_size(&res
);
40 if (!request_mem_region(res
.start
, size
, np
->name
)) {
45 data
->membase
= ioremap(res
.start
, size
);
51 spin_lock_init(&data
->lock
);
53 data
->rcdev
.owner
= THIS_MODULE
;
54 data
->rcdev
.nr_resets
= size
* 8;
55 data
->rcdev
.ops
= &reset_simple_ops
;
56 data
->rcdev
.of_node
= np
;
57 data
->active_low
= true;
59 return reset_controller_register(&data
->rcdev
);
67 * These are the reset controller we need to initialize early on in
68 * our system, before we can even think of using a regular device
70 * The controllers that we can register through the regular device
71 * model are handled by the simple reset driver directly.
73 static const struct of_device_id sunxi_early_reset_dt_ids
[] __initconst
= {
74 { .compatible
= "allwinner,sun6i-a31-ahb1-reset", },
78 void __init
sun6i_reset_init(void)
80 struct device_node
*np
;
82 for_each_matching_node(np
, sunxi_early_reset_dt_ids
)