Commit 8e06053d authored by Fabio Estevam's avatar Fabio Estevam Committed by Mauro Carvalho Chehab

media: fsl-viu: Use the ioread/write32be() accessors

Since commit 29d75068 ("media: fsl-viu: allow building it with
COMPILE_TEST") there were several attempts to fix build failures on
PPC, MICROBLAZE and M68K.

However, such errors are still present as reported by kbuild robot.

Fix the problem by using the ioread/write32be() accessors, which build
fine on all platforms.
Reported-by: default avatarkernel test robot <lkp@intel.com>
Suggested-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Signed-off-by: default avatarFabio Estevam <festevam@gmail.com>
Reviewed-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent db47622c
...@@ -31,12 +31,6 @@ ...@@ -31,12 +31,6 @@
#define DRV_NAME "fsl_viu" #define DRV_NAME "fsl_viu"
#define VIU_VERSION "0.5.1" #define VIU_VERSION "0.5.1"
/* Allow building this driver with COMPILE_TEST */
#if !defined(CONFIG_PPC) && !defined(CONFIG_MICROBLAZE) && !defined(CONFIG_M68K)
#define out_be32(v, a) iowrite32be(a, (void __iomem *)v)
#define in_be32(a) ioread32be((void __iomem *)a)
#endif
#define BUFFER_TIMEOUT msecs_to_jiffies(500) /* 0.5 seconds */ #define BUFFER_TIMEOUT msecs_to_jiffies(500) /* 0.5 seconds */
#define VIU_VID_MEM_LIMIT 4 /* Video memory limit, in Mb */ #define VIU_VID_MEM_LIMIT 4 /* Video memory limit, in Mb */
...@@ -250,8 +244,8 @@ static void viu_start_dma(struct viu_dev *dev) ...@@ -250,8 +244,8 @@ static void viu_start_dma(struct viu_dev *dev)
dev->field = 0; dev->field = 0;
/* Enable DMA operation */ /* Enable DMA operation */
out_be32(&vr->status_cfg, SOFT_RST); iowrite32be(SOFT_RST, &vr->status_cfg);
out_be32(&vr->status_cfg, INT_FIELD_EN); iowrite32be(INT_FIELD_EN, &vr->status_cfg);
} }
static void viu_stop_dma(struct viu_dev *dev) static void viu_stop_dma(struct viu_dev *dev)
...@@ -260,27 +254,27 @@ static void viu_stop_dma(struct viu_dev *dev) ...@@ -260,27 +254,27 @@ static void viu_stop_dma(struct viu_dev *dev)
int cnt = 100; int cnt = 100;
u32 status_cfg; u32 status_cfg;
out_be32(&vr->status_cfg, 0); iowrite32be(0, &vr->status_cfg);
/* Clear pending interrupts */ /* Clear pending interrupts */
status_cfg = in_be32(&vr->status_cfg); status_cfg = ioread32be(&vr->status_cfg);
if (status_cfg & 0x3f0000) if (status_cfg & 0x3f0000)
out_be32(&vr->status_cfg, status_cfg & 0x3f0000); iowrite32be(status_cfg & 0x3f0000, &vr->status_cfg);
if (status_cfg & DMA_ACT) { if (status_cfg & DMA_ACT) {
do { do {
status_cfg = in_be32(&vr->status_cfg); status_cfg = ioread32be(&vr->status_cfg);
if (status_cfg & INT_DMA_END_STATUS) if (status_cfg & INT_DMA_END_STATUS)
break; break;
} while (cnt--); } while (cnt--);
if (cnt < 0) { if (cnt < 0) {
/* timed out, issue soft reset */ /* timed out, issue soft reset */
out_be32(&vr->status_cfg, SOFT_RST); iowrite32be(SOFT_RST, &vr->status_cfg);
out_be32(&vr->status_cfg, 0); iowrite32be(0, &vr->status_cfg);
} else { } else {
/* clear DMA_END and other pending irqs */ /* clear DMA_END and other pending irqs */
out_be32(&vr->status_cfg, status_cfg & 0x3f0000); iowrite32be(status_cfg & 0x3f0000, &vr->status_cfg);
} }
} }
...@@ -434,9 +428,9 @@ inline int buffer_activate(struct viu_dev *dev, struct viu_buf *buf) ...@@ -434,9 +428,9 @@ inline int buffer_activate(struct viu_dev *dev, struct viu_buf *buf)
if (!V4L2_FIELD_HAS_BOTH(buf->vb.field)) if (!V4L2_FIELD_HAS_BOTH(buf->vb.field))
reg_val.dma_inc = 0; reg_val.dma_inc = 0;
out_be32(&vr->dma_inc, reg_val.dma_inc); iowrite32be(reg_val.dma_inc, &vr->dma_inc);
out_be32(&vr->picture_count, reg_val.picture_count); iowrite32be(reg_val.picture_count, &vr->picture_count);
out_be32(&vr->field_base_addr, reg_val.field_base_addr); iowrite32be(reg_val.field_base_addr, &vr->field_base_addr);
mod_timer(&dev->vidq.timeout, jiffies + BUFFER_TIMEOUT); mod_timer(&dev->vidq.timeout, jiffies + BUFFER_TIMEOUT);
return 0; return 0;
} }
...@@ -696,9 +690,9 @@ static int verify_preview(struct viu_dev *dev, struct v4l2_window *win) ...@@ -696,9 +690,9 @@ static int verify_preview(struct viu_dev *dev, struct v4l2_window *win)
inline void viu_activate_overlay(struct viu_reg __iomem *vr) inline void viu_activate_overlay(struct viu_reg __iomem *vr)
{ {
out_be32(&vr->field_base_addr, reg_val.field_base_addr); iowrite32be(reg_val.field_base_addr, &vr->field_base_addr);
out_be32(&vr->dma_inc, reg_val.dma_inc); iowrite32be(reg_val.dma_inc, &vr->dma_inc);
out_be32(&vr->picture_count, reg_val.picture_count); iowrite32be(reg_val.picture_count, &vr->picture_count);
} }
static int viu_setup_preview(struct viu_dev *dev, struct viu_fh *fh) static int viu_setup_preview(struct viu_dev *dev, struct viu_fh *fh)
...@@ -976,14 +970,14 @@ inline void viu_activate_next_buf(struct viu_dev *dev, ...@@ -976,14 +970,14 @@ inline void viu_activate_next_buf(struct viu_dev *dev,
inline void viu_default_settings(struct viu_reg __iomem *vr) inline void viu_default_settings(struct viu_reg __iomem *vr)
{ {
out_be32(&vr->luminance, 0x9512A254); iowrite32be(0x9512A254, &vr->luminance);
out_be32(&vr->chroma_r, 0x03310000); iowrite32be(0x03310000, &vr->chroma_r);
out_be32(&vr->chroma_g, 0x06600F38); iowrite32be(0x06600F38, &vr->chroma_g);
out_be32(&vr->chroma_b, 0x00000409); iowrite32be(0x00000409, &vr->chroma_b);
out_be32(&vr->alpha, 0x000000ff); iowrite32be(0x000000ff, &vr->alpha);
out_be32(&vr->req_alarm, 0x00000090); iowrite32be(0x00000090, &vr->req_alarm);
dprintk(1, "status reg: 0x%08x, field base: 0x%08x\n", dprintk(1, "status reg: 0x%08x, field base: 0x%08x\n",
in_be32(&vr->status_cfg), in_be32(&vr->field_base_addr)); ioread32be(&vr->status_cfg), ioread32be(&vr->field_base_addr));
} }
static void viu_overlay_intr(struct viu_dev *dev, u32 status) static void viu_overlay_intr(struct viu_dev *dev, u32 status)
...@@ -1001,17 +995,15 @@ static void viu_overlay_intr(struct viu_dev *dev, u32 status) ...@@ -1001,17 +995,15 @@ static void viu_overlay_intr(struct viu_dev *dev, u32 status)
if (status & FIELD_NO) if (status & FIELD_NO)
addr += reg_val.dma_inc; addr += reg_val.dma_inc;
out_be32(&vr->field_base_addr, addr); iowrite32be(addr, &vr->field_base_addr);
out_be32(&vr->dma_inc, reg_val.dma_inc); iowrite32be(reg_val.dma_inc, &vr->dma_inc);
out_be32(&vr->status_cfg, iowrite32be((status & 0xffc0ffff) |
(status & 0xffc0ffff) |
(status & INT_ALL_STATUS) | (status & INT_ALL_STATUS) |
reg_val.status_cfg); reg_val.status_cfg, &vr->status_cfg);
} else if (status & INT_VSYNC_STATUS) { } else if (status & INT_VSYNC_STATUS) {
out_be32(&vr->status_cfg, iowrite32be((status & 0xffc0ffff) |
(status & 0xffc0ffff) |
(status & INT_ALL_STATUS) | (status & INT_ALL_STATUS) |
reg_val.status_cfg); reg_val.status_cfg, &vr->status_cfg);
} }
} }
} }
...@@ -1057,12 +1049,11 @@ static void viu_capture_intr(struct viu_dev *dev, u32 status) ...@@ -1057,12 +1049,11 @@ static void viu_capture_intr(struct viu_dev *dev, u32 status)
dprintk(1, "field 1, 0x%lx, dev field %d\n", dprintk(1, "field 1, 0x%lx, dev field %d\n",
(unsigned long)addr, dev->field); (unsigned long)addr, dev->field);
} }
out_be32(&vr->field_base_addr, addr); iowrite32be(addr, &vr->field_base_addr);
out_be32(&vr->dma_inc, reg_val.dma_inc); iowrite32be(reg_val.dma_inc, &vr->dma_inc);
out_be32(&vr->status_cfg, iowrite32be((status & 0xffc0ffff) |
(status & 0xffc0ffff) |
(status & INT_ALL_STATUS) | (status & INT_ALL_STATUS) |
reg_val.status_cfg); reg_val.status_cfg, &vr->status_cfg);
return; return;
} }
} }
...@@ -1074,7 +1065,7 @@ static void viu_capture_intr(struct viu_dev *dev, u32 status) ...@@ -1074,7 +1065,7 @@ static void viu_capture_intr(struct viu_dev *dev, u32 status)
dprintk(1, "viu/0: [%p/%d] 0x%lx/0x%lx: dma complete\n", dprintk(1, "viu/0: [%p/%d] 0x%lx/0x%lx: dma complete\n",
buf, buf->vb.i, buf, buf->vb.i,
(unsigned long)videobuf_to_dma_contig(&buf->vb), (unsigned long)videobuf_to_dma_contig(&buf->vb),
(unsigned long)in_be32(&vr->field_base_addr)); (unsigned long)ioread32be(&vr->field_base_addr));
if (waitqueue_active(&buf->vb.done)) { if (waitqueue_active(&buf->vb.done)) {
list_del(&buf->vb.queue); list_del(&buf->vb.queue);
...@@ -1095,7 +1086,7 @@ static irqreturn_t viu_intr(int irq, void *dev_id) ...@@ -1095,7 +1086,7 @@ static irqreturn_t viu_intr(int irq, void *dev_id)
u32 status; u32 status;
u32 error; u32 error;
status = in_be32(&vr->status_cfg); status = ioread32be(&vr->status_cfg);
if (status & INT_ERROR_STATUS) { if (status & INT_ERROR_STATUS) {
dev->irqs.error_irq++; dev->irqs.error_irq++;
...@@ -1104,8 +1095,8 @@ static irqreturn_t viu_intr(int irq, void *dev_id) ...@@ -1104,8 +1095,8 @@ static irqreturn_t viu_intr(int irq, void *dev_id)
dprintk(1, "Err: error(%d), times:%d!\n", dprintk(1, "Err: error(%d), times:%d!\n",
error >> 4, dev->irqs.error_irq); error >> 4, dev->irqs.error_irq);
/* Clear interrupt error bit and error flags */ /* Clear interrupt error bit and error flags */
out_be32(&vr->status_cfg, iowrite32be((status & 0xffc0ffff) | INT_ERROR_STATUS,
(status & 0xffc0ffff) | INT_ERROR_STATUS); &vr->status_cfg);
} }
if (status & INT_DMA_END_STATUS) { if (status & INT_DMA_END_STATUS) {
...@@ -1134,9 +1125,9 @@ static irqreturn_t viu_intr(int irq, void *dev_id) ...@@ -1134,9 +1125,9 @@ static irqreturn_t viu_intr(int irq, void *dev_id)
} }
/* clear all pending irqs */ /* clear all pending irqs */
status = in_be32(&vr->status_cfg); status = ioread32be(&vr->status_cfg);
out_be32(&vr->status_cfg, iowrite32be((status & 0xffc0ffff) | (status & INT_ALL_STATUS),
(status & 0xffc0ffff) | (status & INT_ALL_STATUS)); &vr->status_cfg);
if (dev->ovenable) { if (dev->ovenable) {
viu_overlay_intr(dev, status); viu_overlay_intr(dev, status);
...@@ -1205,14 +1196,14 @@ static int viu_open(struct file *file) ...@@ -1205,14 +1196,14 @@ static int viu_open(struct file *file)
viu_default_settings(vr); viu_default_settings(vr);
status_cfg = in_be32(&vr->status_cfg); status_cfg = ioread32be(&vr->status_cfg);
out_be32(&vr->status_cfg, iowrite32be(status_cfg & ~(INT_VSYNC_EN | INT_HSYNC_EN |
status_cfg & ~(INT_VSYNC_EN | INT_HSYNC_EN |
INT_FIELD_EN | INT_VSTART_EN | INT_FIELD_EN | INT_VSTART_EN |
INT_DMA_END_EN | INT_ERROR_EN | INT_ECC_EN)); INT_DMA_END_EN | INT_ERROR_EN | INT_ECC_EN),
&vr->status_cfg);
status_cfg = in_be32(&vr->status_cfg); status_cfg = ioread32be(&vr->status_cfg);
out_be32(&vr->status_cfg, status_cfg | INT_ALL_STATUS); iowrite32be(status_cfg | INT_ALL_STATUS, &vr->status_cfg);
spin_lock_init(&fh->vbq_lock); spin_lock_init(&fh->vbq_lock);
videobuf_queue_dma_contig_init(&fh->vb_vidq, &viu_video_qops, videobuf_queue_dma_contig_init(&fh->vb_vidq, &viu_video_qops,
...@@ -1292,16 +1283,16 @@ static int viu_release(struct file *file) ...@@ -1292,16 +1283,16 @@ static int viu_release(struct file *file)
static void viu_reset(struct viu_reg __iomem *reg) static void viu_reset(struct viu_reg __iomem *reg)
{ {
out_be32(&reg->status_cfg, 0); iowrite32be(0, &reg->status_cfg);
out_be32(&reg->luminance, 0x9512a254); iowrite32be(0x9512a254, &reg->luminance);
out_be32(&reg->chroma_r, 0x03310000); iowrite32be(0x03310000, &reg->chroma_r);
out_be32(&reg->chroma_g, 0x06600f38); iowrite32be(0x06600f38, &reg->chroma_g);
out_be32(&reg->chroma_b, 0x00000409); iowrite32be(0x00000409, &reg->chroma_b);
out_be32(&reg->field_base_addr, 0); iowrite32be(0, &reg->field_base_addr);
out_be32(&reg->dma_inc, 0); iowrite32be(0, &reg->dma_inc);
out_be32(&reg->picture_count, 0x01e002d0); iowrite32be(0x01e002d0, &reg->picture_count);
out_be32(&reg->req_alarm, 0x00000090); iowrite32be(0x00000090, &reg->req_alarm);
out_be32(&reg->alpha, 0x000000ff); iowrite32be(0x000000ff, &reg->alpha);
} }
static int viu_mmap(struct file *file, struct vm_area_struct *vma) static int viu_mmap(struct file *file, struct vm_area_struct *vma)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment