flowctrl.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * arch/arm/mach-tegra/flowctrl.c
  3. *
  4. * functions and macros to control the flowcontroller
  5. *
  6. * Copyright (c) 2010-2012, NVIDIA Corporation. All rights reserved.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms and conditions of the GNU General Public License,
  10. * version 2, as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but WITHOUT
  13. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  15. * more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include <linux/init.h>
  21. #include <linux/kernel.h>
  22. #include <linux/io.h>
  23. #include <mach/iomap.h>
  24. #include "flowctrl.h"
  25. u8 flowctrl_offset_halt_cpu[] = {
  26. FLOW_CTRL_HALT_CPU0_EVENTS,
  27. FLOW_CTRL_HALT_CPU1_EVENTS,
  28. FLOW_CTRL_HALT_CPU1_EVENTS + 8,
  29. FLOW_CTRL_HALT_CPU1_EVENTS + 16,
  30. };
  31. u8 flowctrl_offset_cpu_csr[] = {
  32. FLOW_CTRL_CPU0_CSR,
  33. FLOW_CTRL_CPU1_CSR,
  34. FLOW_CTRL_CPU1_CSR + 8,
  35. FLOW_CTRL_CPU1_CSR + 16,
  36. };
  37. static void flowctrl_update(u8 offset, u32 value)
  38. {
  39. void __iomem *addr = IO_ADDRESS(TEGRA_FLOW_CTRL_BASE) + offset;
  40. writel(value, addr);
  41. /* ensure the update has reached the flow controller */
  42. wmb();
  43. readl_relaxed(addr);
  44. }
  45. void flowctrl_write_cpu_csr(unsigned int cpuid, u32 value)
  46. {
  47. return flowctrl_update(flowctrl_offset_halt_cpu[cpuid], value);
  48. }
  49. void flowctrl_write_cpu_halt(unsigned int cpuid, u32 value)
  50. {
  51. return flowctrl_update(flowctrl_offset_cpu_csr[cpuid], value);
  52. }