Commit 71aecd5d authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Mauro Carvalho Chehab

media: atomisp: Replace direct access to MMIO with proper helpers

We have special helpers to access MMIO. Use them.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 89027fea
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/firmware.h> #include <linux/firmware.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/kfifo.h> #include <linux/kfifo.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
...@@ -669,11 +670,10 @@ bool atomisp_buffers_queued_pipe(struct atomisp_video_pipe *pipe) ...@@ -669,11 +670,10 @@ bool atomisp_buffers_queued_pipe(struct atomisp_video_pipe *pipe)
void dump_sp_dmem(struct atomisp_device *isp, unsigned int addr, void dump_sp_dmem(struct atomisp_device *isp, unsigned int addr,
unsigned int size) unsigned int size)
{ {
u32 __iomem *io_virt_addr;
unsigned int data = 0; unsigned int data = 0;
unsigned int size32 = DIV_ROUND_UP(size, sizeof(u32)); unsigned int size32 = DIV_ROUND_UP(size, sizeof(u32));
dev_dbg(isp->dev, "atomisp_io_base:%p\n", atomisp_io_base); dev_dbg(isp->dev, "atomisp mmio base: %p\n", isp->base);
dev_dbg(isp->dev, "%s, addr:0x%x, size: %d, size32: %d\n", __func__, dev_dbg(isp->dev, "%s, addr:0x%x, size: %d, size32: %d\n", __func__,
addr, size, size32); addr, size, size32);
if (size32 * 4 + addr > 0x4000) { if (size32 * 4 + addr > 0x4000) {
...@@ -682,13 +682,12 @@ void dump_sp_dmem(struct atomisp_device *isp, unsigned int addr, ...@@ -682,13 +682,12 @@ void dump_sp_dmem(struct atomisp_device *isp, unsigned int addr,
return; return;
} }
addr += SP_DMEM_BASE; addr += SP_DMEM_BASE;
io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF); addr &= 0x003FFFFF;
do { do {
data = *io_virt_addr; data = readl(isp->base + addr);
dev_dbg(isp->dev, "%s, \t [0x%x]:0x%x\n", __func__, addr, data); dev_dbg(isp->dev, "%s, \t [0x%x]:0x%x\n", __func__, addr, data);
io_virt_addr += sizeof(u32); addr += sizeof(u32);
size32 -= 1; } while (--size32);
} while (size32 > 0);
} }
static struct videobuf_buffer *atomisp_css_frame_to_vbuf( static struct videobuf_buffer *atomisp_css_frame_to_vbuf(
......
...@@ -29,8 +29,6 @@ struct atomisp_sub_device; ...@@ -29,8 +29,6 @@ struct atomisp_sub_device;
struct video_device; struct video_device;
enum atomisp_input_stream_id; enum atomisp_input_stream_id;
extern void __iomem *atomisp_io_base;
struct atomisp_metadata_buf { struct atomisp_metadata_buf {
struct ia_css_metadata *metadata; struct ia_css_metadata *metadata;
void *md_vptr; void *md_vptr;
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "sh_css_hrt.h" #include "sh_css_hrt.h"
#include "ia_css_isys.h" #include "ia_css_isys.h"
#include <linux/io.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
/* Assume max number of ACC stages */ /* Assume max number of ACC stages */
...@@ -67,92 +68,94 @@ struct bayer_ds_factor { ...@@ -67,92 +68,94 @@ struct bayer_ds_factor {
static void atomisp_css2_hw_store_8(hrt_address addr, uint8_t data) static void atomisp_css2_hw_store_8(hrt_address addr, uint8_t data)
{ {
s8 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF); struct atomisp_device *isp = dev_get_drvdata(atomisp_dev);
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&mmio_lock, flags); spin_lock_irqsave(&mmio_lock, flags);
*io_virt_addr = data; writeb(data, isp->base + (addr & 0x003FFFFF));
spin_unlock_irqrestore(&mmio_lock, flags); spin_unlock_irqrestore(&mmio_lock, flags);
} }
static void atomisp_css2_hw_store_16(hrt_address addr, uint16_t data) static void atomisp_css2_hw_store_16(hrt_address addr, uint16_t data)
{ {
s16 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF); struct atomisp_device *isp = dev_get_drvdata(atomisp_dev);
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&mmio_lock, flags); spin_lock_irqsave(&mmio_lock, flags);
*io_virt_addr = data; writew(data, isp->base + (addr & 0x003FFFFF));
spin_unlock_irqrestore(&mmio_lock, flags); spin_unlock_irqrestore(&mmio_lock, flags);
} }
void atomisp_css2_hw_store_32(hrt_address addr, uint32_t data) void atomisp_css2_hw_store_32(hrt_address addr, uint32_t data)
{ {
s32 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF); struct atomisp_device *isp = dev_get_drvdata(atomisp_dev);
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&mmio_lock, flags); spin_lock_irqsave(&mmio_lock, flags);
*io_virt_addr = data; writel(data, isp->base + (addr & 0x003FFFFF));
spin_unlock_irqrestore(&mmio_lock, flags); spin_unlock_irqrestore(&mmio_lock, flags);
} }
static uint8_t atomisp_css2_hw_load_8(hrt_address addr) static uint8_t atomisp_css2_hw_load_8(hrt_address addr)
{ {
s8 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF); struct atomisp_device *isp = dev_get_drvdata(atomisp_dev);
unsigned long flags; unsigned long flags;
u8 ret; u8 ret;
spin_lock_irqsave(&mmio_lock, flags); spin_lock_irqsave(&mmio_lock, flags);
ret = *io_virt_addr; ret = readb(isp->base + (addr & 0x003FFFFF));
spin_unlock_irqrestore(&mmio_lock, flags); spin_unlock_irqrestore(&mmio_lock, flags);
return ret; return ret;
} }
static uint16_t atomisp_css2_hw_load_16(hrt_address addr) static uint16_t atomisp_css2_hw_load_16(hrt_address addr)
{ {
s16 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF); struct atomisp_device *isp = dev_get_drvdata(atomisp_dev);
unsigned long flags; unsigned long flags;
u16 ret; u16 ret;
spin_lock_irqsave(&mmio_lock, flags); spin_lock_irqsave(&mmio_lock, flags);
ret = *io_virt_addr; ret = readw(isp->base + (addr & 0x003FFFFF));
spin_unlock_irqrestore(&mmio_lock, flags); spin_unlock_irqrestore(&mmio_lock, flags);
return ret; return ret;
} }
static uint32_t atomisp_css2_hw_load_32(hrt_address addr) static uint32_t atomisp_css2_hw_load_32(hrt_address addr)
{ {
s32 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF); struct atomisp_device *isp = dev_get_drvdata(atomisp_dev);
unsigned long flags; unsigned long flags;
u32 ret; u32 ret;
spin_lock_irqsave(&mmio_lock, flags); spin_lock_irqsave(&mmio_lock, flags);
ret = *io_virt_addr; ret = readl(isp->base + (addr & 0x003FFFFF));
spin_unlock_irqrestore(&mmio_lock, flags); spin_unlock_irqrestore(&mmio_lock, flags);
return ret; return ret;
} }
static void atomisp_css2_hw_store(hrt_address addr, static void atomisp_css2_hw_store(hrt_address addr, const void *from, uint32_t n)
const void *from, uint32_t n)
{ {
s8 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF); struct atomisp_device *isp = dev_get_drvdata(atomisp_dev);
unsigned long flags; unsigned long flags;
unsigned int i; unsigned int i;
addr &= 0x003FFFFF;
spin_lock_irqsave(&mmio_lock, flags); spin_lock_irqsave(&mmio_lock, flags);
for (i = 0; i < n; i++, io_virt_addr++, from++) for (i = 0; i < n; i++, from++)
*io_virt_addr = *(s8 *)from; writeb(*(s8 *)from, isp->base + addr + i);
spin_unlock_irqrestore(&mmio_lock, flags); spin_unlock_irqrestore(&mmio_lock, flags);
} }
static void atomisp_css2_hw_load(hrt_address addr, void *to, uint32_t n) static void atomisp_css2_hw_load(hrt_address addr, void *to, uint32_t n)
{ {
s8 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF); struct atomisp_device *isp = dev_get_drvdata(atomisp_dev);
unsigned long flags; unsigned long flags;
unsigned int i; unsigned int i;
addr &= 0x003FFFFF;
spin_lock_irqsave(&mmio_lock, flags); spin_lock_irqsave(&mmio_lock, flags);
for (i = 0; i < n; i++, to++, io_virt_addr++) for (i = 0; i < n; i++, to++)
*(s8 *)to = *io_virt_addr; *(s8 *)to = readb(isp->base + addr + i);
spin_unlock_irqrestore(&mmio_lock, flags); spin_unlock_irqrestore(&mmio_lock, flags);
} }
......
...@@ -221,6 +221,7 @@ struct atomisp_device { ...@@ -221,6 +221,7 @@ struct atomisp_device {
struct media_device media_dev; struct media_device media_dev;
struct atomisp_platform_data *pdata; struct atomisp_platform_data *pdata;
void *mmu_l1_base; void *mmu_l1_base;
void __iomem *base;
const struct firmware *firmware; const struct firmware *firmware;
struct pm_qos_request pm_qos; struct pm_qos_request pm_qos;
......
...@@ -127,8 +127,6 @@ MODULE_PARM_DESC(pad_h, "extra data for ISP processing"); ...@@ -127,8 +127,6 @@ MODULE_PARM_DESC(pad_h, "extra data for ISP processing");
struct device *atomisp_dev; struct device *atomisp_dev;
void __iomem *atomisp_io_base;
static const struct atomisp_freq_scaling_rule dfs_rules_merr[] = { static const struct atomisp_freq_scaling_rule dfs_rules_merr[] = {
{ {
.width = ISP_FREQ_RULE_ANY, .width = ISP_FREQ_RULE_ANY,
...@@ -1533,7 +1531,6 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i ...@@ -1533,7 +1531,6 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
const struct atomisp_platform_data *pdata; const struct atomisp_platform_data *pdata;
struct atomisp_device *isp; struct atomisp_device *isp;
unsigned int start; unsigned int start;
void __iomem *base;
int err, val; int err, val;
u32 irq; u32 irq;
...@@ -1562,13 +1559,6 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i ...@@ -1562,13 +1559,6 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
goto ioremap_fail; goto ioremap_fail;
} }
base = pcim_iomap_table(pdev)[ATOM_ISP_PCI_BAR];
dev_dbg(&pdev->dev, "base: %p\n", base);
atomisp_io_base = base;
dev_dbg(&pdev->dev, "atomisp_io_base: %p\n", atomisp_io_base);
isp = devm_kzalloc(&pdev->dev, sizeof(*isp), GFP_KERNEL); isp = devm_kzalloc(&pdev->dev, sizeof(*isp), GFP_KERNEL);
if (!isp) { if (!isp) {
err = -ENOMEM; err = -ENOMEM;
...@@ -1576,9 +1566,12 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i ...@@ -1576,9 +1566,12 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
} }
isp->dev = &pdev->dev; isp->dev = &pdev->dev;
isp->base = pcim_iomap_table(pdev)[ATOM_ISP_PCI_BAR];
isp->sw_contex.power_state = ATOM_ISP_POWER_UP; isp->sw_contex.power_state = ATOM_ISP_POWER_UP;
isp->saved_regs.ispmmadr = start; isp->saved_regs.ispmmadr = start;
dev_dbg(&pdev->dev, "atomisp mmio base: %p\n", isp->base);
rt_mutex_init(&isp->mutex); rt_mutex_init(&isp->mutex);
mutex_init(&isp->streamoff_mutex); mutex_init(&isp->streamoff_mutex);
spin_lock_init(&isp->lock); spin_lock_init(&isp->lock);
...@@ -1586,6 +1579,8 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i ...@@ -1586,6 +1579,8 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
/* This is not a true PCI device on SoC, so the delay is not needed. */ /* This is not a true PCI device on SoC, so the delay is not needed. */
pdev->d3_delay = 0; pdev->d3_delay = 0;
pci_set_drvdata(pdev, isp);
switch (id->device & ATOMISP_PCI_DEVICE_SOC_MASK) { switch (id->device & ATOMISP_PCI_DEVICE_SOC_MASK) {
case ATOMISP_PCI_DEVICE_SOC_MRFLD: case ATOMISP_PCI_DEVICE_SOC_MRFLD:
isp->media_dev.hw_revision = isp->media_dev.hw_revision =
...@@ -1716,7 +1711,6 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i ...@@ -1716,7 +1711,6 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
} }
pci_set_master(pdev); pci_set_master(pdev);
pci_set_drvdata(pdev, isp);
err = pci_enable_msi(pdev); err = pci_enable_msi(pdev);
if (err) { if (err) {
......
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