WIP FPC-III support
[linux/fpc-iii.git] / drivers / media / pci / tw5864 / tw5864-util.c
blobb9cebe9d1740f50a9a2b54bb59cf9c67124e6c85
1 // SPDX-License-Identifier: GPL-2.0
2 #include "tw5864.h"
4 void tw5864_indir_writeb(struct tw5864_dev *dev, u16 addr, u8 data)
6 int retries = 30000;
8 while (tw_readl(TW5864_IND_CTL) & BIT(31) && --retries)
10 if (!retries)
11 dev_err(&dev->pci->dev,
12 "tw_indir_writel() retries exhausted before writing\n");
14 tw_writel(TW5864_IND_DATA, data);
15 tw_writel(TW5864_IND_CTL, addr << 2 | TW5864_RW | TW5864_ENABLE);
18 u8 tw5864_indir_readb(struct tw5864_dev *dev, u16 addr)
20 int retries = 30000;
22 while (tw_readl(TW5864_IND_CTL) & BIT(31) && --retries)
24 if (!retries)
25 dev_err(&dev->pci->dev,
26 "tw_indir_readl() retries exhausted before reading\n");
28 tw_writel(TW5864_IND_CTL, addr << 2 | TW5864_ENABLE);
30 retries = 30000;
31 while (tw_readl(TW5864_IND_CTL) & BIT(31) && --retries)
33 if (!retries)
34 dev_err(&dev->pci->dev,
35 "tw_indir_readl() retries exhausted at reading\n");
37 return tw_readl(TW5864_IND_DATA);