Skip to content

Commit 71aecd5

Browse files
andy-shevmchehab
authored andcommitted
media: atomisp: Replace direct access to MMIO with proper helpers
We have special helpers to access MMIO. Use them. Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 89027fe commit 71aecd5

File tree

5 files changed

+35
-40
lines changed

5 files changed

+35
-40
lines changed

drivers/staging/media/atomisp/pci/atomisp_cmd.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/firmware.h>
2222
#include <linux/pci.h>
2323
#include <linux/interrupt.h>
24+
#include <linux/io.h>
2425
#include <linux/kernel.h>
2526
#include <linux/kfifo.h>
2627
#include <linux/pm_runtime.h>
@@ -669,11 +670,10 @@ bool atomisp_buffers_queued_pipe(struct atomisp_video_pipe *pipe)
669670
void dump_sp_dmem(struct atomisp_device *isp, unsigned int addr,
670671
unsigned int size)
671672
{
672-
u32 __iomem *io_virt_addr;
673673
unsigned int data = 0;
674674
unsigned int size32 = DIV_ROUND_UP(size, sizeof(u32));
675675

676-
dev_dbg(isp->dev, "atomisp_io_base:%p\n", atomisp_io_base);
676+
dev_dbg(isp->dev, "atomisp mmio base: %p\n", isp->base);
677677
dev_dbg(isp->dev, "%s, addr:0x%x, size: %d, size32: %d\n", __func__,
678678
addr, size, size32);
679679
if (size32 * 4 + addr > 0x4000) {
@@ -682,13 +682,12 @@ void dump_sp_dmem(struct atomisp_device *isp, unsigned int addr,
682682
return;
683683
}
684684
addr += SP_DMEM_BASE;
685-
io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF);
685+
addr &= 0x003FFFFF;
686686
do {
687-
data = *io_virt_addr;
687+
data = readl(isp->base + addr);
688688
dev_dbg(isp->dev, "%s, \t [0x%x]:0x%x\n", __func__, addr, data);
689-
io_virt_addr += sizeof(u32);
690-
size32 -= 1;
691-
} while (size32 > 0);
689+
addr += sizeof(u32);
690+
} while (--size32);
692691
}
693692

694693
static struct videobuf_buffer *atomisp_css_frame_to_vbuf(

drivers/staging/media/atomisp/pci/atomisp_compat.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ struct atomisp_sub_device;
2929
struct video_device;
3030
enum atomisp_input_stream_id;
3131

32-
extern void __iomem *atomisp_io_base;
33-
3432
struct atomisp_metadata_buf {
3533
struct ia_css_metadata *metadata;
3634
void *md_vptr;

drivers/staging/media/atomisp/pci/atomisp_compat_css20.c

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "sh_css_hrt.h"
3939
#include "ia_css_isys.h"
4040

41+
#include <linux/io.h>
4142
#include <linux/pm_runtime.h>
4243

4344
/* Assume max number of ACC stages */
@@ -67,92 +68,94 @@ struct bayer_ds_factor {
6768

6869
static void atomisp_css2_hw_store_8(hrt_address addr, uint8_t data)
6970
{
70-
s8 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF);
71+
struct atomisp_device *isp = dev_get_drvdata(atomisp_dev);
7172
unsigned long flags;
7273

7374
spin_lock_irqsave(&mmio_lock, flags);
74-
*io_virt_addr = data;
75+
writeb(data, isp->base + (addr & 0x003FFFFF));
7576
spin_unlock_irqrestore(&mmio_lock, flags);
7677
}
7778

7879
static void atomisp_css2_hw_store_16(hrt_address addr, uint16_t data)
7980
{
80-
s16 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF);
81+
struct atomisp_device *isp = dev_get_drvdata(atomisp_dev);
8182
unsigned long flags;
8283

8384
spin_lock_irqsave(&mmio_lock, flags);
84-
*io_virt_addr = data;
85+
writew(data, isp->base + (addr & 0x003FFFFF));
8586
spin_unlock_irqrestore(&mmio_lock, flags);
8687
}
8788

8889
void atomisp_css2_hw_store_32(hrt_address addr, uint32_t data)
8990
{
90-
s32 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF);
91+
struct atomisp_device *isp = dev_get_drvdata(atomisp_dev);
9192
unsigned long flags;
9293

9394
spin_lock_irqsave(&mmio_lock, flags);
94-
*io_virt_addr = data;
95+
writel(data, isp->base + (addr & 0x003FFFFF));
9596
spin_unlock_irqrestore(&mmio_lock, flags);
9697
}
9798

9899
static uint8_t atomisp_css2_hw_load_8(hrt_address addr)
99100
{
100-
s8 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF);
101+
struct atomisp_device *isp = dev_get_drvdata(atomisp_dev);
101102
unsigned long flags;
102103
u8 ret;
103104

104105
spin_lock_irqsave(&mmio_lock, flags);
105-
ret = *io_virt_addr;
106+
ret = readb(isp->base + (addr & 0x003FFFFF));
106107
spin_unlock_irqrestore(&mmio_lock, flags);
107108
return ret;
108109
}
109110

110111
static uint16_t atomisp_css2_hw_load_16(hrt_address addr)
111112
{
112-
s16 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF);
113+
struct atomisp_device *isp = dev_get_drvdata(atomisp_dev);
113114
unsigned long flags;
114115
u16 ret;
115116

116117
spin_lock_irqsave(&mmio_lock, flags);
117-
ret = *io_virt_addr;
118+
ret = readw(isp->base + (addr & 0x003FFFFF));
118119
spin_unlock_irqrestore(&mmio_lock, flags);
119120
return ret;
120121
}
121122

122123
static uint32_t atomisp_css2_hw_load_32(hrt_address addr)
123124
{
124-
s32 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF);
125+
struct atomisp_device *isp = dev_get_drvdata(atomisp_dev);
125126
unsigned long flags;
126127
u32 ret;
127128

128129
spin_lock_irqsave(&mmio_lock, flags);
129-
ret = *io_virt_addr;
130+
ret = readl(isp->base + (addr & 0x003FFFFF));
130131
spin_unlock_irqrestore(&mmio_lock, flags);
131132
return ret;
132133
}
133134

134-
static void atomisp_css2_hw_store(hrt_address addr,
135-
const void *from, uint32_t n)
135+
static void atomisp_css2_hw_store(hrt_address addr, const void *from, uint32_t n)
136136
{
137-
s8 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF);
137+
struct atomisp_device *isp = dev_get_drvdata(atomisp_dev);
138138
unsigned long flags;
139139
unsigned int i;
140140

141+
addr &= 0x003FFFFF;
141142
spin_lock_irqsave(&mmio_lock, flags);
142-
for (i = 0; i < n; i++, io_virt_addr++, from++)
143-
*io_virt_addr = *(s8 *)from;
143+
for (i = 0; i < n; i++, from++)
144+
writeb(*(s8 *)from, isp->base + addr + i);
145+
144146
spin_unlock_irqrestore(&mmio_lock, flags);
145147
}
146148

147149
static void atomisp_css2_hw_load(hrt_address addr, void *to, uint32_t n)
148150
{
149-
s8 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF);
151+
struct atomisp_device *isp = dev_get_drvdata(atomisp_dev);
150152
unsigned long flags;
151153
unsigned int i;
152154

155+
addr &= 0x003FFFFF;
153156
spin_lock_irqsave(&mmio_lock, flags);
154-
for (i = 0; i < n; i++, to++, io_virt_addr++)
155-
*(s8 *)to = *io_virt_addr;
157+
for (i = 0; i < n; i++, to++)
158+
*(s8 *)to = readb(isp->base + addr + i);
156159
spin_unlock_irqrestore(&mmio_lock, flags);
157160
}
158161

drivers/staging/media/atomisp/pci/atomisp_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ struct atomisp_device {
221221
struct media_device media_dev;
222222
struct atomisp_platform_data *pdata;
223223
void *mmu_l1_base;
224+
void __iomem *base;
224225
const struct firmware *firmware;
225226

226227
struct pm_qos_request pm_qos;

drivers/staging/media/atomisp/pci/atomisp_v4l2.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ MODULE_PARM_DESC(pad_h, "extra data for ISP processing");
127127

128128
struct device *atomisp_dev;
129129

130-
void __iomem *atomisp_io_base;
131-
132130
static const struct atomisp_freq_scaling_rule dfs_rules_merr[] = {
133131
{
134132
.width = ISP_FREQ_RULE_ANY,
@@ -1533,7 +1531,6 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
15331531
const struct atomisp_platform_data *pdata;
15341532
struct atomisp_device *isp;
15351533
unsigned int start;
1536-
void __iomem *base;
15371534
int err, val;
15381535
u32 irq;
15391536

@@ -1562,30 +1559,28 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
15621559
goto ioremap_fail;
15631560
}
15641561

1565-
base = pcim_iomap_table(pdev)[ATOM_ISP_PCI_BAR];
1566-
dev_dbg(&pdev->dev, "base: %p\n", base);
1567-
1568-
atomisp_io_base = base;
1569-
1570-
dev_dbg(&pdev->dev, "atomisp_io_base: %p\n", atomisp_io_base);
1571-
15721562
isp = devm_kzalloc(&pdev->dev, sizeof(*isp), GFP_KERNEL);
15731563
if (!isp) {
15741564
err = -ENOMEM;
15751565
goto atomisp_dev_alloc_fail;
15761566
}
15771567

15781568
isp->dev = &pdev->dev;
1569+
isp->base = pcim_iomap_table(pdev)[ATOM_ISP_PCI_BAR];
15791570
isp->sw_contex.power_state = ATOM_ISP_POWER_UP;
15801571
isp->saved_regs.ispmmadr = start;
15811572

1573+
dev_dbg(&pdev->dev, "atomisp mmio base: %p\n", isp->base);
1574+
15821575
rt_mutex_init(&isp->mutex);
15831576
mutex_init(&isp->streamoff_mutex);
15841577
spin_lock_init(&isp->lock);
15851578

15861579
/* This is not a true PCI device on SoC, so the delay is not needed. */
15871580
pdev->d3_delay = 0;
15881581

1582+
pci_set_drvdata(pdev, isp);
1583+
15891584
switch (id->device & ATOMISP_PCI_DEVICE_SOC_MASK) {
15901585
case ATOMISP_PCI_DEVICE_SOC_MRFLD:
15911586
isp->media_dev.hw_revision =
@@ -1716,7 +1711,6 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
17161711
}
17171712

17181713
pci_set_master(pdev);
1719-
pci_set_drvdata(pdev, isp);
17201714

17211715
err = pci_enable_msi(pdev);
17221716
if (err) {

0 commit comments

Comments
 (0)