utils.h 687 B

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef _NAS782X_UTILS_H
  2. #define _NAS782X_UTILS_H
  3. #include <linux/io.h>
  4. #include <mach/hardware.h>
  5. static inline void oxnas_register_clear_mask(void __iomem *p, unsigned mask)
  6. {
  7. u32 val = readl_relaxed(p);
  8. val &= ~mask;
  9. writel_relaxed(val, p);
  10. }
  11. static inline void oxnas_register_set_mask(void __iomem *p, unsigned mask)
  12. {
  13. u32 val = readl_relaxed(p);
  14. val |= mask;
  15. writel_relaxed(val, p);
  16. }
  17. static inline void oxnas_register_value_mask(void __iomem *p,
  18. unsigned mask, unsigned new_value)
  19. {
  20. /* TODO sanity check mask & new_value = new_value */
  21. u32 val = readl_relaxed(p);
  22. val &= ~mask;
  23. val |= new_value;
  24. writel_relaxed(val, p);
  25. }
  26. #endif /* _NAS782X_UTILS_H */