reset.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (c) 2013, The Linux Foundation. All rights reserved.
  3. *
  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.
  7. *
  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.
  12. */
  13. #include <linux/bitops.h>
  14. #include <linux/export.h>
  15. #include <linux/regmap.h>
  16. #include <linux/reset-controller.h>
  17. #include <linux/delay.h>
  18. #include "reset.h"
  19. static int qcom_reset(struct reset_controller_dev *rcdev, unsigned long id)
  20. {
  21. rcdev->ops->assert(rcdev, id);
  22. udelay(1);
  23. rcdev->ops->deassert(rcdev, id);
  24. return 0;
  25. }
  26. static int
  27. qcom_reset_assert(struct reset_controller_dev *rcdev, unsigned long id)
  28. {
  29. struct qcom_reset_controller *rst;
  30. const struct qcom_reset_map *map;
  31. u32 mask;
  32. rst = to_qcom_reset_controller(rcdev);
  33. map = &rst->reset_map[id];
  34. mask = BIT(map->bit);
  35. return regmap_update_bits(rst->regmap, map->reg, mask, mask);
  36. }
  37. static int
  38. qcom_reset_deassert(struct reset_controller_dev *rcdev, unsigned long id)
  39. {
  40. struct qcom_reset_controller *rst;
  41. const struct qcom_reset_map *map;
  42. u32 mask;
  43. rst = to_qcom_reset_controller(rcdev);
  44. map = &rst->reset_map[id];
  45. mask = BIT(map->bit);
  46. return regmap_update_bits(rst->regmap, map->reg, mask, 0);
  47. }
  48. struct reset_control_ops qcom_reset_ops = {
  49. .reset = qcom_reset,
  50. .assert = qcom_reset_assert,
  51. .deassert = qcom_reset_deassert,
  52. };
  53. EXPORT_SYMBOL_GPL(qcom_reset_ops);