hal_hwspinlock.c 584 B

12345678910111213141516171819202122232425262728293031323334
  1. #include <sunxi_hal_common.h>
  2. #include <hal_hwspinlock.h>
  3. #include <hal_clk.h>
  4. #include "hwspinlock.h"
  5. void hal_hwspinlock_init(void)
  6. {
  7. /*
  8. * the clk and gate should init in kernel
  9. */
  10. /* hal_clock_enable(HAL_CLK_PERIPH_SPINLOCK); */
  11. }
  12. int hal_hwspinlock_check_taken(int num)
  13. {
  14. return !!(readl(SPINLOCK_STATUS_REG) & (1 << num));
  15. }
  16. void hal_hwspinlock_get(int num)
  17. {
  18. unsigned long addr = SPINLOCK_LOCK_REG(num);
  19. while (readl(addr) != 0);
  20. }
  21. void hal_hwspinlock_put(int num)
  22. {
  23. unsigned long addr = SPINLOCK_LOCK_REG(num);
  24. writel(0, addr);
  25. }