why iowrite32_rep() doesn't work, I have to use the iowrite32() with a loop
ayaka
ayaka at soulik.info
Thu Nov 16 15:12:24 EST 2017
Hello All:
I am writing a driver, I need to write a series of values into the
registers. The old code use the writel_relaxed() to avoid flushing cache
between echo of register. I want to use the recommended way of the io
operations, so I choose the iowrite32()_req(), but I found what it wrote
nothing, I read it at once after a memory barrier, there is no contents
there. But it I use the iowrite32() with a loop, it works well and the
registers of the device is configured. What make this problem?
The io memory is assigned with devm_ioremap_resource().
void mpp_dev_write_seq(struct rockchip_mpp_dev *mpp_dev, unsigned long
offset,
void *buffer, unsigned long count)
{
int i;
#if 1
for (i = 0; i < count; i++) {
u32 *cur = (u32 *)buffer;
u32 pos = offset + i * 4;
cur += i;
mpp_debug(DEBUG_SET_REG, "write reg[%03d]: %08x\n",
pos, *cur);
iowrite32(*cur, mpp_dev->reg_base + pos);
}
#else
iowrite32_rep(mpp_dev->reg_base + offset, buffer, count);
mb();
for (i = 0; i < count; i++) {
u32 cur = 0;
u32 pos = offset / 4 + i;
cur = ioread32(mpp_dev->reg_base + pos * 4);
pr_info("get reg[%03d]: %08x\n", pos, cur);
}
#endif
}
More information about the Kernelnewbies
mailing list