tw5864-util.c 894 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include "tw5864.h"
  2. void tw5864_indir_writeb(struct tw5864_dev *dev, u16 addr, u8 data)
  3. {
  4. int retries = 30000;
  5. while (tw_readl(TW5864_IND_CTL) & BIT(31) && --retries)
  6. ;
  7. if (!retries)
  8. dev_err(&dev->pci->dev,
  9. "tw_indir_writel() retries exhausted before writing\n");
  10. tw_writel(TW5864_IND_DATA, data);
  11. tw_writel(TW5864_IND_CTL, addr << 2 | TW5864_RW | TW5864_ENABLE);
  12. }
  13. u8 tw5864_indir_readb(struct tw5864_dev *dev, u16 addr)
  14. {
  15. int retries = 30000;
  16. while (tw_readl(TW5864_IND_CTL) & BIT(31) && --retries)
  17. ;
  18. if (!retries)
  19. dev_err(&dev->pci->dev,
  20. "tw_indir_readl() retries exhausted before reading\n");
  21. tw_writel(TW5864_IND_CTL, addr << 2 | TW5864_ENABLE);
  22. retries = 30000;
  23. while (tw_readl(TW5864_IND_CTL) & BIT(31) && --retries)
  24. ;
  25. if (!retries)
  26. dev_err(&dev->pci->dev,
  27. "tw_indir_readl() retries exhausted at reading\n");
  28. return tw_readl(TW5864_IND_DATA);
  29. }