ccu_reset.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (C) 2016 Maxime Ripard
  3. * Maxime Ripard <maxime.ripard@free-electrons.com>
  4. *
  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. */
  10. #include <linux/io.h>
  11. #include <linux/reset-controller.h>
  12. #include "ccu_reset.h"
  13. static int ccu_reset_assert(struct reset_controller_dev *rcdev,
  14. unsigned long id)
  15. {
  16. struct ccu_reset *ccu = rcdev_to_ccu_reset(rcdev);
  17. const struct ccu_reset_map *map = &ccu->reset_map[id];
  18. unsigned long flags;
  19. u32 reg;
  20. spin_lock_irqsave(ccu->lock, flags);
  21. reg = readl(ccu->base + map->reg);
  22. writel(reg & ~map->bit, ccu->base + map->reg);
  23. spin_unlock_irqrestore(ccu->lock, flags);
  24. return 0;
  25. }
  26. static int ccu_reset_deassert(struct reset_controller_dev *rcdev,
  27. unsigned long id)
  28. {
  29. struct ccu_reset *ccu = rcdev_to_ccu_reset(rcdev);
  30. const struct ccu_reset_map *map = &ccu->reset_map[id];
  31. unsigned long flags;
  32. u32 reg;
  33. spin_lock_irqsave(ccu->lock, flags);
  34. reg = readl(ccu->base + map->reg);
  35. writel(reg | map->bit, ccu->base + map->reg);
  36. spin_unlock_irqrestore(ccu->lock, flags);
  37. return 0;
  38. }
  39. const struct reset_control_ops ccu_reset_ops = {
  40. .assert = ccu_reset_assert,
  41. .deassert = ccu_reset_deassert,
  42. };