Skip to content

Commit a970137

Browse files
mripardpH5
authored andcommitted
reset: simple: Add reset callback
The reset-simple code lacks a reset callback that is still pretty easy to implement. The only real thing to consider is the delay needed for a device to be reset, so let's expose that as part of the reset-simple driver data. Reviewed-by: Philipp Zabel <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
1 parent 9357b04 commit a970137

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

drivers/reset/reset-simple.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* Maxime Ripard <[email protected]>
1212
*/
1313

14+
#include <linux/delay.h>
1415
#include <linux/device.h>
1516
#include <linux/err.h>
1617
#include <linux/io.h>
@@ -63,6 +64,24 @@ static int reset_simple_deassert(struct reset_controller_dev *rcdev,
6364
return reset_simple_update(rcdev, id, false);
6465
}
6566

67+
static int reset_simple_reset(struct reset_controller_dev *rcdev,
68+
unsigned long id)
69+
{
70+
struct reset_simple_data *data = to_reset_simple_data(rcdev);
71+
int ret;
72+
73+
if (!data->reset_us)
74+
return -ENOTSUPP;
75+
76+
ret = reset_simple_assert(rcdev, id);
77+
if (ret)
78+
return ret;
79+
80+
usleep_range(data->reset_us, data->reset_us * 2);
81+
82+
return reset_simple_deassert(rcdev, id);
83+
}
84+
6685
static int reset_simple_status(struct reset_controller_dev *rcdev,
6786
unsigned long id)
6887
{
@@ -80,6 +99,7 @@ static int reset_simple_status(struct reset_controller_dev *rcdev,
8099
const struct reset_control_ops reset_simple_ops = {
81100
.assert = reset_simple_assert,
82101
.deassert = reset_simple_deassert,
102+
.reset = reset_simple_reset,
83103
.status = reset_simple_status,
84104
};
85105
EXPORT_SYMBOL_GPL(reset_simple_ops);

include/linux/reset/reset-simple.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,20 @@
2727
* @status_active_low: if true, bits read back as cleared while the reset is
2828
* asserted. Otherwise, bits read back as set while the
2929
* reset is asserted.
30+
* @reset_us: Minimum delay in microseconds needed that needs to be
31+
* waited for between an assert and a deassert to reset the
32+
* device. If multiple consumers with different delay
33+
* requirements are connected to this controller, it must
34+
* be the largest minimum delay. 0 means that such a delay is
35+
* unknown and the reset operation is unsupported.
3036
*/
3137
struct reset_simple_data {
3238
spinlock_t lock;
3339
void __iomem *membase;
3440
struct reset_controller_dev rcdev;
3541
bool active_low;
3642
bool status_active_low;
43+
unsigned int reset_us;
3744
};
3845

3946
extern const struct reset_control_ops reset_simple_ops;

0 commit comments

Comments
 (0)