Linux 4.16.11
[linux/fpc-iii.git] / drivers / clk / qcom / reset.c
blob0324d8daab9bc01e6099ed78770dab235f9fd98d
1 /*
2 * Copyright (c) 2013, The Linux Foundation. All rights reserved.
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #include <linux/bitops.h>
15 #include <linux/export.h>
16 #include <linux/regmap.h>
17 #include <linux/reset-controller.h>
18 #include <linux/delay.h>
20 #include "reset.h"
22 static int qcom_reset(struct reset_controller_dev *rcdev, unsigned long id)
24 rcdev->ops->assert(rcdev, id);
25 udelay(1);
26 rcdev->ops->deassert(rcdev, id);
27 return 0;
30 static int
31 qcom_reset_assert(struct reset_controller_dev *rcdev, unsigned long id)
33 struct qcom_reset_controller *rst;
34 const struct qcom_reset_map *map;
35 u32 mask;
37 rst = to_qcom_reset_controller(rcdev);
38 map = &rst->reset_map[id];
39 mask = BIT(map->bit);
41 return regmap_update_bits(rst->regmap, map->reg, mask, mask);
44 static int
45 qcom_reset_deassert(struct reset_controller_dev *rcdev, unsigned long id)
47 struct qcom_reset_controller *rst;
48 const struct qcom_reset_map *map;
49 u32 mask;
51 rst = to_qcom_reset_controller(rcdev);
52 map = &rst->reset_map[id];
53 mask = BIT(map->bit);
55 return regmap_update_bits(rst->regmap, map->reg, mask, 0);
58 const struct reset_control_ops qcom_reset_ops = {
59 .reset = qcom_reset,
60 .assert = qcom_reset_assert,
61 .deassert = qcom_reset_deassert,
63 EXPORT_SYMBOL_GPL(qcom_reset_ops);