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