sh_eth: fix EESIPR values for SH77{34|63}
[linux/fpc-iii.git] / drivers / clk / sunxi-ng / ccu_reset.c
blob6c31d48783a73edf7aec5302509561a4802dcf3b
1 /*
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.
9 */
11 #include <linux/io.h>
12 #include <linux/reset-controller.h>
14 #include "ccu_reset.h"
16 static int ccu_reset_assert(struct reset_controller_dev *rcdev,
17 unsigned long id)
19 struct ccu_reset *ccu = rcdev_to_ccu_reset(rcdev);
20 const struct ccu_reset_map *map = &ccu->reset_map[id];
21 unsigned long flags;
22 u32 reg;
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);
31 return 0;
34 static int ccu_reset_deassert(struct reset_controller_dev *rcdev,
35 unsigned long id)
37 struct ccu_reset *ccu = rcdev_to_ccu_reset(rcdev);
38 const struct ccu_reset_map *map = &ccu->reset_map[id];
39 unsigned long flags;
40 u32 reg;
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);
49 return 0;
52 const struct reset_control_ops ccu_reset_ops = {
53 .assert = ccu_reset_assert,
54 .deassert = ccu_reset_deassert,