2 * Copyright (C) 2016 Maxime Ripard
3 * Maxime Ripard <maxime.ripard@free-electrons.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or (at your option) any later version.
12 #include <linux/reset-controller.h>
14 #include "ccu_reset.h"
16 static int ccu_reset_assert(struct reset_controller_dev
*rcdev
,
19 struct ccu_reset
*ccu
= rcdev_to_ccu_reset(rcdev
);
20 const struct ccu_reset_map
*map
= &ccu
->reset_map
[id
];
24 spin_lock_irqsave(ccu
->lock
, flags
);
26 reg
= readl(ccu
->base
+ map
->reg
);
27 writel(reg
& ~map
->bit
, ccu
->base
+ map
->reg
);
29 spin_unlock_irqrestore(ccu
->lock
, flags
);
34 static int ccu_reset_deassert(struct reset_controller_dev
*rcdev
,
37 struct ccu_reset
*ccu
= rcdev_to_ccu_reset(rcdev
);
38 const struct ccu_reset_map
*map
= &ccu
->reset_map
[id
];
42 spin_lock_irqsave(ccu
->lock
, flags
);
44 reg
= readl(ccu
->base
+ map
->reg
);
45 writel(reg
| map
->bit
, ccu
->base
+ map
->reg
);
47 spin_unlock_irqrestore(ccu
->lock
, flags
);
52 const struct reset_control_ops ccu_reset_ops
= {
53 .assert = ccu_reset_assert
,
54 .deassert
= ccu_reset_deassert
,