1 // SPDX-License-Identifier: GPL-2.0-or-later
3 // Actions Semi Owl SoCs Reset Management Unit driver
5 // Copyright (c) 2018 Linaro Ltd.
6 // Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
8 #include <linux/delay.h>
9 #include <linux/regmap.h>
10 #include <linux/reset-controller.h>
12 #include "owl-reset.h"
14 static int owl_reset_assert(struct reset_controller_dev
*rcdev
,
17 struct owl_reset
*reset
= to_owl_reset(rcdev
);
18 const struct owl_reset_map
*map
= &reset
->reset_map
[id
];
20 return regmap_update_bits(reset
->regmap
, map
->reg
, map
->bit
, 0);
23 static int owl_reset_deassert(struct reset_controller_dev
*rcdev
,
26 struct owl_reset
*reset
= to_owl_reset(rcdev
);
27 const struct owl_reset_map
*map
= &reset
->reset_map
[id
];
29 return regmap_update_bits(reset
->regmap
, map
->reg
, map
->bit
, map
->bit
);
32 static int owl_reset_reset(struct reset_controller_dev
*rcdev
,
35 owl_reset_assert(rcdev
, id
);
37 owl_reset_deassert(rcdev
, id
);
42 static int owl_reset_status(struct reset_controller_dev
*rcdev
,
45 struct owl_reset
*reset
= to_owl_reset(rcdev
);
46 const struct owl_reset_map
*map
= &reset
->reset_map
[id
];
50 ret
= regmap_read(reset
->regmap
, map
->reg
, ®
);
55 * The reset control API expects 0 if reset is not asserted,
56 * which is the opposite of what our hardware uses.
58 return !(map
->bit
& reg
);
61 const struct reset_control_ops owl_reset_ops
= {
62 .assert = owl_reset_assert
,
63 .deassert
= owl_reset_deassert
,
64 .reset
= owl_reset_reset
,
65 .status
= owl_reset_status
,