Commit 69a03e36 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab
Browse files

media: atomisp: get rid of an iomem abstraction layer



The hive_isp_css_custom_host_hrt.h code, together
with atomisp_helper.h, provides an abstraction layer for
some functions inside atomisp_compat_css20.c and atomisp_cmd.c.

There's no good reason for that. In a matter of fact, after
removing the abstraction, the code looked a lot cleaner
and easier to understand.

So, get rid of them.

While here, get rid also of the udelay(1) abstraction code.

Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 662fb4fc
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -665,6 +665,7 @@ bool atomisp_buffers_queued_pipe(struct atomisp_video_pipe *pipe)
void dump_sp_dmem(struct atomisp_device *isp, unsigned int addr,
		  unsigned int size)
{
	u32 __iomem *io_virt_addr;
	unsigned int data = 0;
	unsigned int size32 = DIV_ROUND_UP(size, sizeof(u32));

@@ -677,11 +678,11 @@ void dump_sp_dmem(struct atomisp_device *isp, unsigned int addr,
		return;
	}
	addr += SP_DMEM_BASE;
	io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF);
	do {
		data = _hrt_master_port_uload_32(addr);

		data = *io_virt_addr;
		dev_dbg(isp->dev, "%s, \t [0x%x]:0x%x\n", __func__, addr, data);
		addr += sizeof(unsigned int);
		io_virt_addr += sizeof(u32);
		size32 -= 1;
	} while (size32 > 0);
}
+0 −10
Original line number Diff line number Diff line
@@ -65,16 +65,6 @@ bool atomisp_buffers_queued(struct atomisp_sub_device *asd);
/* ISP2401 */
bool atomisp_buffers_queued_pipe(struct atomisp_video_pipe *pipe);

/* TODO:should be here instead of atomisp_helper.h
extern void __iomem *atomisp_io_base;

static inline void __iomem *atomisp_get_io_virt_addr(unsigned int address)
{
	void __iomem *ret = atomisp_io_base + (address & 0x003FFFFF);
	return ret;
}
*/

/*
 * Interrupt functions
 */
+2 −0
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ struct atomisp_sub_device;
struct video_device;
enum atomisp_input_stream_id;

extern void __iomem *atomisp_io_base;

struct atomisp_metadata_buf {
	struct ia_css_metadata *metadata;
	void *md_vptr;
+27 −18
Original line number Diff line number Diff line
@@ -69,60 +69,66 @@ struct bayer_ds_factor {

static void atomisp_css2_hw_store_8(hrt_address addr, uint8_t data)
{
	s8 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF);
	unsigned long flags;

	spin_lock_irqsave(&mmio_lock, flags);
	_hrt_master_port_store_8(addr, data);
	*io_virt_addr = data;
	spin_unlock_irqrestore(&mmio_lock, flags);
}

static void atomisp_css2_hw_store_16(hrt_address addr, uint16_t data)
{
	s16 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF);
	unsigned long flags;

	spin_lock_irqsave(&mmio_lock, flags);
	_hrt_master_port_store_16(addr, data);
	*io_virt_addr = data;
	spin_unlock_irqrestore(&mmio_lock, flags);
}

void atomisp_css2_hw_store_32(hrt_address addr, uint32_t data)
{
	s32 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF);
	unsigned long flags;

	spin_lock_irqsave(&mmio_lock, flags);
	_hrt_master_port_store_32(addr, data);
	*io_virt_addr = data;
	spin_unlock_irqrestore(&mmio_lock, flags);
}

static uint8_t atomisp_css2_hw_load_8(hrt_address addr)
{
	s8 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF);
	unsigned long flags;
	u8 ret;

	spin_lock_irqsave(&mmio_lock, flags);
	ret = _hrt_master_port_load_8(addr);
	ret = *io_virt_addr;
	spin_unlock_irqrestore(&mmio_lock, flags);
	return ret;
}

static uint16_t atomisp_css2_hw_load_16(hrt_address addr)
{
	s16 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF);
	unsigned long flags;
	u16 ret;

	spin_lock_irqsave(&mmio_lock, flags);
	ret = _hrt_master_port_load_16(addr);
	ret = *io_virt_addr;
	spin_unlock_irqrestore(&mmio_lock, flags);
	return ret;
}

static uint32_t atomisp_css2_hw_load_32(hrt_address addr)
{
	s32 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF);
	unsigned long flags;
	u32 ret;

	spin_lock_irqsave(&mmio_lock, flags);
	ret = _hrt_master_port_load_32(addr);
	ret = *io_virt_addr;
	spin_unlock_irqrestore(&mmio_lock, flags);
	return ret;
}
@@ -130,27 +136,25 @@ static uint32_t atomisp_css2_hw_load_32(hrt_address addr)
static void atomisp_css2_hw_store(hrt_address addr,
				  const void *from, uint32_t n)
{
	s8 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF);
	unsigned long flags;
	unsigned int i;
	unsigned int _to = (unsigned int)addr;
	const char *_from = (const char *)from;

	spin_lock_irqsave(&mmio_lock, flags);
	for (i = 0; i < n; i++, _to++, _from++)
		_hrt_master_port_store_8(_to, *_from);
	for (i = 0; i < n; i++, io_virt_addr++, from++)
		*io_virt_addr = *(s8 *)from;
	spin_unlock_irqrestore(&mmio_lock, flags);
}

static void atomisp_css2_hw_load(hrt_address addr, void *to, uint32_t n)
{
	s8 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF);
	unsigned long flags;
	unsigned int i;
	char *_to = (char *)to;
	unsigned int _from = (unsigned int)addr;

	spin_lock_irqsave(&mmio_lock, flags);
	for (i = 0; i < n; i++, _to++, _from++)
		*_to = _hrt_master_port_load_8(_from);
	for (i = 0; i < n; i++, to++, io_virt_addr++)
		*(s8 *)to = *io_virt_addr;
	spin_unlock_irqrestore(&mmio_lock, flags);
}

@@ -992,9 +996,9 @@ void atomisp_css_rx_clear_irq_info(enum mipi_port_id port,
int atomisp_css_irq_enable(struct atomisp_device *isp,
			   enum ia_css_irq_info info, bool enable)
{
	dev_dbg(isp->dev, "%s: css irq info 0x%08x: %s.\n",
	dev_dbg(isp->dev, "%s: css irq info 0x%08x: %s (%d).\n",
		__func__, info,
		enable ? "enable" : "disable");
		enable ? "enable" : "disable", enable);
	if (ia_css_irq_enable(info, enable)) {
		dev_warn(isp->dev, "%s:Invalid irq info: 0x%08x when %s.\n",
			 __func__, info,
@@ -4292,8 +4296,13 @@ bool atomisp_css_valid_sof(struct atomisp_device *isp)
		struct atomisp_sub_device *asd = &isp->asd[i];
		/* Loop for each css vc stream */
		for (j = 0; j < ATOMISP_INPUT_STREAM_NUM; j++) {
			if (asd->stream_env[j].stream &&
			    asd->stream_env[j].stream_config.mode ==
			if (!asd->stream_env[j].stream)
				continue;

			dev_dbg(isp->dev,
				"stream #%d: mode: %d\n", j,
				asd->stream_env[j].stream_config.mode);
			if (asd->stream_env[j].stream_config.mode ==
			    IA_CSS_INPUT_MODE_BUFFERED_SENSOR)
				return false;
		}
+0 −29
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Support for Medifield PNW Camera Imaging ISP subsystem.
 *
 * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
 *
 * Copyright (c) 2010 Silicon Hive www.siliconhive.com.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License version
 * 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 *
 */
#ifndef _atomisp_helper_h_
#define _atomisp_helper_h_
extern void __iomem *atomisp_io_base;

static inline void __iomem *atomisp_get_io_virt_addr(unsigned int address)
{
	void __iomem *ret = atomisp_io_base + (address & 0x003FFFFF);
	return ret;
}
#endif
Loading