0001
0002
0003
0004
0005
0006 #include <linux/bitops.h>
0007 #include <linux/export.h>
0008 #include <linux/regmap.h>
0009 #include <linux/reset-controller.h>
0010 #include <linux/delay.h>
0011
0012 #include "reset.h"
0013
0014 static int qcom_reset(struct reset_controller_dev *rcdev, unsigned long id)
0015 {
0016 rcdev->ops->assert(rcdev, id);
0017 udelay(1);
0018 rcdev->ops->deassert(rcdev, id);
0019 return 0;
0020 }
0021
0022 static int
0023 qcom_reset_assert(struct reset_controller_dev *rcdev, unsigned long id)
0024 {
0025 struct qcom_reset_controller *rst;
0026 const struct qcom_reset_map *map;
0027 u32 mask;
0028
0029 rst = to_qcom_reset_controller(rcdev);
0030 map = &rst->reset_map[id];
0031 mask = BIT(map->bit);
0032
0033 return regmap_update_bits(rst->regmap, map->reg, mask, mask);
0034 }
0035
0036 static int
0037 qcom_reset_deassert(struct reset_controller_dev *rcdev, unsigned long id)
0038 {
0039 struct qcom_reset_controller *rst;
0040 const struct qcom_reset_map *map;
0041 u32 mask;
0042
0043 rst = to_qcom_reset_controller(rcdev);
0044 map = &rst->reset_map[id];
0045 mask = BIT(map->bit);
0046
0047 return regmap_update_bits(rst->regmap, map->reg, mask, 0);
0048 }
0049
0050 const struct reset_control_ops qcom_reset_ops = {
0051 .reset = qcom_reset,
0052 .assert = qcom_reset_assert,
0053 .deassert = qcom_reset_deassert,
0054 };
0055 EXPORT_SYMBOL_GPL(qcom_reset_ops);