crypto: simd - correctly take reqsize of wrapped skcipher into account
[linux/fpc-iii.git] / drivers / clk / sunxi-ng / ccu_reset.c
blobb67149143554e45247fd55450a4134367a773fe9
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/delay.h>
12 #include <linux/io.h>
13 #include <linux/reset-controller.h>
15 #include "ccu_reset.h"
17 static int ccu_reset_assert(struct reset_controller_dev *rcdev,
18 unsigned long id)
20 struct ccu_reset *ccu = rcdev_to_ccu_reset(rcdev);
21 const struct ccu_reset_map *map = &ccu->reset_map[id];
22 unsigned long flags;
23 u32 reg;
25 spin_lock_irqsave(ccu->lock, flags);
27 reg = readl(ccu->base + map->reg);
28 writel(reg & ~map->bit, ccu->base + map->reg);
30 spin_unlock_irqrestore(ccu->lock, flags);
32 return 0;
35 static int ccu_reset_deassert(struct reset_controller_dev *rcdev,
36 unsigned long id)
38 struct ccu_reset *ccu = rcdev_to_ccu_reset(rcdev);
39 const struct ccu_reset_map *map = &ccu->reset_map[id];
40 unsigned long flags;
41 u32 reg;
43 spin_lock_irqsave(ccu->lock, flags);
45 reg = readl(ccu->base + map->reg);
46 writel(reg | map->bit, ccu->base + map->reg);
48 spin_unlock_irqrestore(ccu->lock, flags);
50 return 0;
53 static int ccu_reset_reset(struct reset_controller_dev *rcdev,
54 unsigned long id)
56 ccu_reset_assert(rcdev, id);
57 udelay(10);
58 ccu_reset_deassert(rcdev, id);
60 return 0;
63 static int ccu_reset_status(struct reset_controller_dev *rcdev,
64 unsigned long id)
66 struct ccu_reset *ccu = rcdev_to_ccu_reset(rcdev);
67 const struct ccu_reset_map *map = &ccu->reset_map[id];
70 * The reset control API expects 0 if reset is not asserted,
71 * which is the opposite of what our hardware uses.
73 return !(map->bit & readl(ccu->base + map->reg));
76 const struct reset_control_ops ccu_reset_ops = {
77 .assert = ccu_reset_assert,
78 .deassert = ccu_reset_deassert,
79 .reset = ccu_reset_reset,
80 .status = ccu_reset_status,