drivers/media/platform: add Cix VPU support

This commit is contained in:
Hsun Lai
2025-09-10 14:49:51 +08:00
parent 3142018d11
commit cb7fa9fcec
65 changed files with 38528 additions and 0 deletions

View File

@@ -1,2 +1,4 @@
# SPDX-License-Identifier: GPL-2.0-only
source "drivers/media/platform/cix/linlon-aeu/Kconfig"
source "drivers/media/platform/cix/cix_vpu/Kconfig"

View File

@@ -1,2 +1,4 @@
# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_LINLON_AEU) += linlon-aeu/
obj-$(CONFIG_VIDEO_LINLON) += cix_vpu/

View File

@@ -0,0 +1,52 @@
###########################################################
# Set the include-path according to the defined interface.
###########################################################
ccflags-y += -I$(src) -I$(src)/if -I$(src)/dev -I$(src)/if/v4l2 -I$(src)/external
ccflags-$(CONFIG_VIDEO_LINLON_FTRACE) += -DMVX_LOG_FTRACE_ENABLE
ccflags-$(CONFIG_VIDEO_LINLON_PRINT_FILE) += -DMVX_LOG_PRINT_FILE_ENABLE
ccflags-y += $(EXTRA_CCFLAGS)
###########################################################
# Define build targets and what files to include.
###########################################################
# Amvx module
obj-$(CONFIG_VIDEO_LINLON) := amvx.o
# Add objects for if module.
if-y := if/mvx_if.o \
if/mvx_buffer.o \
if/mvx_firmware_cache.o \
if/mvx_firmware.o \
if/mvx_firmware_v2.o \
if/mvx_firmware_v3.o \
if/mvx_mmu.o \
if/mvx_secure.o \
if/mvx_session.o
# Add external interface.
if-y += if/v4l2/mvx_ext_v4l2.o \
if/v4l2/mvx_v4l2_buffer.o \
if/v4l2/mvx_v4l2_session.o \
if/v4l2/mvx_v4l2_vidioc.o \
if/v4l2/mvx_v4l2_fops.o \
if/v4l2/mvx_v4l2_ctrls.o
# Add objects for dev module.
dev-y := dev/mvx_dev.o \
dev/mvx_hwreg.o \
dev/mvx_hwreg_v500.o \
dev/mvx_hwreg_v550.o \
dev/mvx_hwreg_v61.o \
dev/mvx_hwreg_v52_v76.o \
dev/mvx_lsid.o \
dev/mvx_scheduler.o \
mvx_pm_runtime.o
# Add driver objects.
amvx-y := mvx_driver.o \
mvx_seq.o \
mvx_log.o \
mvx_log_group.o \
$(if-y) $(dev-y)

View File

@@ -0,0 +1,20 @@
config VIDEO_LINLON
tristate "Linlon VPU support."
depends on VIDEO_DEV
default m
help
This enables support for the Linlon VPU family.
config VIDEO_LINLON_FTRACE
depends on VIDEO_LINLON
bool "Send kernel space logs to ftrace."
default n
help
Send kernel space logs to ftrace.
config VIDEO_LINLON_PRINT_FILE
depends on VIDEO_LINLON
bool "Append file and line number to kernel space log messages."
default y
help
Append file and line number to kernel space log messages.

View File

@@ -0,0 +1,11 @@
all: mono_v4l2
mono_v4l2:
@env CONFIG_VIDEO_LINLON=m CONFIG_VIDEO_LINLON_MONO=y CONFIG_VIDEO_LINLON_IF_V4L2=y $(MAKE) -C $(KDIR) M=$(CURDIR) modules
clean:
@rm -rf *.ko
@find . -type f -name '*.o' -delete
@rm -rf *.mod.c
@rm -f Module.symvers
@rm -f modules.order

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,49 @@
/*
* The confidential and proprietary information contained in this file may
* only be used by a person authorised under and to the extent permitted
* by a subsisting licensing agreement from Arm Technology (China) Co., Ltd.
*
* (C) COPYRIGHT 2021-2021 Arm Technology (China) Co., Ltd.
* ALL RIGHTS RESERVED
*
* This entire notice must be reproduced on all copies of this file
* and copies of this file may only be made by a person if such person is
* permitted to do so under the terms of a subsisting license agreement
* from Arm Technology (China) Co., Ltd.
*
* SPDX-License-Identifier: GPL-2.0-only
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef _MVX_DEV_H_
#define _MVX_DEV_H_
/****************************************************************************
* Exported functions
****************************************************************************/
/**
* mvx_dev_init() - Initialize the dev device.
*/
int mvx_dev_init(void);
/**
* mvx_dev_exit() - Remove and exit the dev device.
*/
void mvx_dev_exit(void);
#endif /* _MVX_DEV_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,382 @@
/*
* The confidential and proprietary information contained in this file may
* only be used by a person authorised under and to the extent permitted
* by a subsisting licensing agreement from Arm Technology (China) Co., Ltd.
*
* (C) COPYRIGHT 2021-2021 Arm Technology (China) Co., Ltd.
* ALL RIGHTS RESERVED
*
* This entire notice must be reproduced on all copies of this file
* and copies of this file may only be made by a person if such person is
* permitted to do so under the terms of a subsisting license agreement
* from Arm Technology (China) Co., Ltd.
*
* SPDX-License-Identifier: GPL-2.0-only
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef _MVX_HW_REG_
#define _MVX_HW_REG_
/****************************************************************************
* Includes
****************************************************************************/
#include <linux/debugfs.h>
#include <linux/types.h>
#include <linux/ioport.h>
#include "mvx_if.h"
#include "mvx_lsid.h"
/****************************************************************************
* Defines
****************************************************************************/
#define MVX_HWREG_FUSE_DISABLE_AFBC (1 << 0)
#define MVX_HWREG_FUSE_DISABLE_REAL (1 << 1)
#define MVX_HWREG_FUSE_DISABLE_VPX (1 << 2)
#define MVX_HWREG_FUSE_DISABLE_HEVC (1 << 3)
#define MVE_JOBQUEUE_JOB_BITS 8
#define MVE_JOBQUEUE_JOB_MASK ((1 << MVE_JOBQUEUE_JOB_BITS) - 1)
#define MVE_JOBQUEUE_JOB_INVALID 0xf
#define MVE_JOBQUEUE_NJOBS 4
#define MVE_JOBQUEUE_LSID_SHIFT 0
#define MVE_JOBQUEUE_LSID_BITS 4
#define MVE_JOBQUEUE_LSID_MASK ((1 << MVE_JOBQUEUE_LSID_BITS) - 1)
#define MVE_JOBQUEUE_NCORES_SHIFT 4
#define MVE_JOBQUEUE_NCORES_BITS 4
#define MVE_CORELSID_LSID_BITS 4
#define MVX_CORELSID_LSID_MASK ((1 << MVE_CORELSID_LSID_BITS) - 1)
#define MVE_CTRL_DISALLOW_SHIFT 0
#define MVE_CTRL_DISALLOW_BITS 8
#define MVE_CTRL_DISALLOW_MASK ((1 << MVE_CTRL_DISALLOW_BITS) - 1)
#define MVE_CTRL_MAXCORES_SHIFT 8
#define MVE_CTRL_MAXCORES_BITS 4
#define MVE_CTRL_MAXCORES_MASK ((1 << MVE_CTRL_MAXCORES_BITS) - 1)
#define MVE_ALLOC_FREE 0
#define MVE_ALLOC_NON_PROTECTED 1
#define MVE_ALLOC_PROTECTED 2
#define MVE_BUSTCTRL_REF_SHIFT 2
/* These bits reset to zero and should be zero for normal operation. */
#define MVE_CLKFORCE_CORE_CLK_SHIFT 0
#define MVE_CLKFORCE_CORE_CLK_BITS 8
#define MVE_CLKFORCE_SCHED_CLK_SHIFT 8
#define MVE_CLKFORCE_SCHED_CLK_BITS 1
#define MVE_CLKFORCE_CORE_PWR_SHIFT 9
#define MVE_CLKFORCE_CORE_PWR_BITS 1
/* RCUS pgctrl register distribution */
#define MVX_RCSU_HWREG_CLOCK_QCHANNEL_ENABLE (1 << 0)
/* RCUS strap-pin0 register distribution */
#define MVX_RCSU_HWREG_DISABLE_AFBC (1 << 0)
#define MVX_RCSU_HWREG_DISABLE_REAL (1 << 1)
#define MVX_RCSU_HWREG_DISABLE_VPX (1 << 2)
#define MVX_RCSU_HWREG_DISABLE_HEVC (1 << 3)
#define MVX_RCSU_HWREG_PSO_D_M_PWON_SHIFT 4
#define MVX_RCSU_HWREG_PSO_D_M_PWON_BITS 8
#define MVX_RCSU_HWREG_PSO_D_M_PWON_MASK ((1 << MVX_RCSU_HWREG_PSO_D_M_ASSERT_BITS) - 1)
#define MVX_RCSU_HWREG_PSO_ACK_ISO_PWON_SHIFT 12
#define MVX_RCSU_HWREG_PSO_ACK_ISO_PWON_BITS 8
#define MVX_RCSU_HWREG_PSO_ACK_ISO_PWON_MASK ((1 << MVX_RCSU_HWREG_PSO_ACK_ISO_PWON_BITS) - 1)
#define MVX_RCSU_HWREG_PSO_D_M_PWOFF_SHIFT 20
#define MVX_RCSU_HWREG_PSO_D_M_PWOFF_BITS 8
#define MVX_RCSU_HWREG_PSO_D_M_PWOFF_MASK ((1 << MVX_RCSU_HWREG_PSO_D_M_PWOFF_BITS) - 1)
#define MVX_RCSU_HWREG_ENPWOFF_SHIFT 28
#define MVX_RCSU_HWREG_ENPWOFF_BITS 4
#define MVX_RCSU_HWREG_ENPWOFF_MASK ((1 << MVX_RCSU_HWREG_ENPWOFF_BITS) - 1)
/* RCUS strap-pin2 register distribution */
#define MVX_RCSU_HWREG_HARVESTING_SHIFT 4
#define MVX_RCSU_HWREG_HARVESTING_BITS 4
#define MVX_RCSU_HWREG_HARVESTING_MASK ((1 << MVX_RCSU_HWREG_HARVESTING_BITS) - 1)
#define MVX_NUMBER_OF_LSID 4
#define MVX_NUMBER_OF_CORES 4
/* Timeout(ms) of wait VPU clear terminate register */
#define MVX_HWREG_TERMINATE_TIMEOUT 100
/****************************************************************************
* Types
****************************************************************************/
struct device;
/**
* enum mvx_hwreg_what - Hardware registers that can be read or written.
*/
enum mvx_hwreg_what {
MVX_HWREG_HARDWARE_ID,
MVX_HWREG_ENABLE,
MVX_HWREG_NCORES,
MVX_HWREG_NLSID,
MVX_HWREG_CORELSID,
MVX_HWREG_JOBQUEUE,
MVX_HWREG_IRQVE,
MVX_HWREG_CLKFORCE,
MVX_HWREG_SVNREV,
MVX_HWREG_FUSE,
MVX_HWREG_PROTCTRL,
MVX_HWREG_BUSCTRL,
MVX_HWREG_RESET,
MVX_HWREG_WHAT_MAX
};
/**
* enum mvx_rcsu_hwreg_what - Hardware rcsu registers that can be read or written.
*/
enum mvx_rcsu_hwreg_what {
MVX_RCSU_HWREG_PGCTRL,
MVX_RCSU_HWREG_STRAP_PIN0,
MVX_RCSU_HWREG_STRAP_PIN1,
MVX_RCSU_HWREG_STRAP_PIN2,
MVX_RCSU_HWREG_WHAT_MAX
};
/**
* enum mvx_hwreg_lsid - Hardware registers per LSID.
*/
enum mvx_hwreg_lsid {
MVX_HWREG_CTRL,
MVX_HWREG_MMU_CTRL,
MVX_HWREG_NPROT,
MVX_HWREG_ALLOC,
MVX_HWREG_FLUSH_ALL,
MVX_HWREG_SCHED,
MVX_HWREG_TERMINATE,
MVX_HWREG_LIRQVE,
MVX_HWREG_IRQHOST,
MVX_HWREG_INTSIG,
MVX_HWREG_STREAMID,
MVX_HWREG_BUSATTR_0,
MVX_HWREG_BUSATTR_1,
MVX_HWREG_BUSATTR_2,
MVX_HWREG_BUSATTR_3,
MVX_HWREG_LSID_MAX
};
/**
* enum mvx_busctrl_ref_type
* MVE_BUSTCTRL_REF_DEFAULT : 128-byte bursts are used for reference pixel data.
* MVE_BUSTCTRL_REF_MIX : a mix of 64-byte and 128-byte bursts are used for
* reference pixel data.
*/
enum mvx_busctrl_ref_type {
MVE_BUSTCTRL_REF_DEFAULT,
MVE_BUSTCTRL_REF_MIX
};
/**
* enum mvx_busctrl_split_type for configures how the video processor performs
* AXI burst accesses.
*/
enum mvx_busctrl_split_type {
MVE_BUSTCTRL_SPLIT_128,
MVE_BUSTCTRL_SPLIT_256,
MVE_BUSTCTRL_SPLIT_512
};
struct mvx_hwreg;
/**
* struct mvx_lsid_hwreg - Helper struct used for debugfs reading of lsid
* dependent registers.
*/
struct mvx_lsid_hwreg {
struct mvx_hwreg *hwreg;
unsigned int lsid;
};
/**
* struct mvx_hwreg - Context class for the hardware register interface.
*/
struct mvx_hwreg {
struct device *dev;
struct resource *rcsu_res;
void *rcsu_registers;
struct resource *res;
void *registers;
struct mvx_lsid_hwreg lsid_hwreg[MVX_LSID_MAX];
struct mvx_hw_ver hw_ver;
uint32_t fuse;
uint32_t ncores;
uint32_t nlsid;
uint32_t core_mask;
wait_queue_head_t wait_queue;
struct {
void (*get_formats)(enum mvx_direction direction,
uint64_t *formats);
} ops;
};
/****************************************************************************
* Exported functions
****************************************************************************/
/**
* mvx_hwreg_construct() - Construct the hardware register object.
* @hwreg: Pointer to hwreg object.
* @dev: Pointer to device struct.
* @rcsu_res: RCSU memory resource.
* @res: Memory resource.
* @parent: Parent debugfs directory entry.
*
* Return: 0 on success, else error code.
*/
int mvx_hwreg_construct(struct mvx_hwreg *hwreg,
struct device *dev,
struct resource *rcsu_res,
struct resource *res,
struct dentry *parent);
/**
* mvx_hwreg_init() - Initialize hardware register object.
* @hwreg: Pointer to hwreg object.
*
* Return: 0 on success, else error code.
*/
int mvx_hwreg_init(struct mvx_hwreg *hwreg);
/**
* mvx_hwreg_destruct() - Destroy the hardware register object.
* @hwreg: Pointer to hwreg object.
*/
void mvx_hwreg_destruct(struct mvx_hwreg *hwreg);
/**
* mvx_hwreg_read() - Read hardware register.
* @hwreg: Pointer to hwreg object.
* @what: Which register to read.
*
* Return: Value of register.
*/
uint32_t mvx_hwreg_read(struct mvx_hwreg *hwreg,
enum mvx_hwreg_what what);
/**
* mvx_hwreg_write() - Write hardware register.
* @hwreg: Pointer to hwreg object.
* @what: Which register to write.
* @value: Value to write.
*/
void mvx_hwreg_write(struct mvx_hwreg *hwreg,
enum mvx_hwreg_what what,
uint32_t value);
/**
* mvx_hwreg_read_lsid() - Read LSID hardware register.
* @hwreg: Pointer to hwreg object.
* @lsid: LSID register index.
* @what: Which register to read.
*
* Return: Value of register.
*/
uint32_t mvx_hwreg_read_lsid(struct mvx_hwreg *hwreg,
unsigned int lsid,
enum mvx_hwreg_lsid what);
/**
* mvx_hwreg_write_lsid() - Write LSID hardware register.
* @hwreg: Pointer to hwreg object.
* @lsid: LSID register index.
* @what: Which register to write.
* @value: Value to write.
*/
void mvx_hwreg_write_lsid(struct mvx_hwreg *hwreg,
unsigned int lsid,
enum mvx_hwreg_lsid what,
uint32_t value);
/**
* mvx_hwreg_read_rcsu() - Read rcsu hardware register.
* @hwreg: Pointer to rcsu hwreg object.
* @what: Which register to read.
*
* Return: Value of register.
*/
uint32_t mvx_hwreg_read_rcsu(struct mvx_hwreg *hwreg,
enum mvx_rcsu_hwreg_what what);
/**
* mvx_hwreg_write_rcsu() - Write rcsu hardware register.
* @hwreg: Pointer to rcsu hwreg object.
* @what: Which register to write.
* @value: Value to write.
*/
void mvx_hwreg_write_rcsu(struct mvx_hwreg *hwreg,
enum mvx_rcsu_hwreg_what what,
uint32_t value);
/**
* mvx_hwreg_get_hw_id() - Get hardware id.
* @hwreg: Pointer to hwreg object.
*
* Return: Hardware id.
*/
enum mvx_hw_id mvx_hwreg_get_hw_id(struct mvx_hwreg *hwreg);
/**
* mvx_hwreg_get_hw_ver() - Get hardware id.
* @hwreg: Pointer to hwreg object.
* @hw_ver: Pointer to destination mvx_hw_ver object.
*
*/
void mvx_hwreg_get_hw_ver(struct mvx_hwreg *hwreg, struct mvx_hw_ver *hw_ver);
/**
* mvx_hwreg_get_fuse() - Get hardware fuse.
* @hwreg: Pointer to hwreg object.
*
* Return: Value of hardware fuse.
*/
uint32_t mvx_hwreg_get_fuse(struct mvx_hwreg *hwreg);
/**
* mvx_hwreg_get_ncores() - Get hardware core number.
* @hwreg: Pointer to hwreg object.
*
* Return: Value of hardware core number.
*/
uint32_t mvx_hwreg_get_ncores(struct mvx_hwreg *hwreg);
/**
* mvx_hwreg_get_nlsid() - Get hardware lsid number.
* @hwreg: Pointer to hwreg object.
*
* Return: Value of hardware lsid number.
*/
uint32_t mvx_hwreg_get_nlsid(struct mvx_hwreg *hwreg);
/**
* mvx_hwreg_get_core_mask() - Get hardware core mask according harvesting.
* @hwreg: Pointer to hwreg object.
*
* Return: Value of hardware core mask.
*/
uint32_t mvx_hwreg_get_core_mask(struct mvx_hwreg *hwreg);
#endif /* _MVX_HW_REG_ */

View File

@@ -0,0 +1,65 @@
/*
* The confidential and proprietary information contained in this file may
* only be used by a person authorised under and to the extent permitted
* by a subsisting licensing agreement from Arm Technology (China) Co., Ltd.
*
* (C) COPYRIGHT 2021-2021 Arm Technology (China) Co., Ltd.
* ALL RIGHTS RESERVED
*
* This entire notice must be reproduced on all copies of this file
* and copies of this file may only be made by a person if such person is
* permitted to do so under the terms of a subsisting license agreement
* from Arm Technology (China) Co., Ltd.
*
* SPDX-License-Identifier: GPL-2.0-only
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/****************************************************************************
* Includes
****************************************************************************/
#include "mvx_bitops.h"
#include "mvx_hwreg_v500.h"
/****************************************************************************
* Exported functions
****************************************************************************/
void mvx_hwreg_get_formats_v500(enum mvx_direction direction,
uint64_t *formats)
{
if (direction == MVX_DIR_INPUT) {
mvx_set_bit(MVX_FORMAT_H263, formats);
mvx_set_bit(MVX_FORMAT_H264, formats);
mvx_set_bit(MVX_FORMAT_MPEG2, formats);
mvx_set_bit(MVX_FORMAT_MPEG4, formats);
mvx_set_bit(MVX_FORMAT_RV, formats);
mvx_set_bit(MVX_FORMAT_VC1, formats);
mvx_set_bit(MVX_FORMAT_VP8, formats);
mvx_set_bit(MVX_FORMAT_YUV420_I420, formats);
mvx_set_bit(MVX_FORMAT_YUV420_NV12, formats);
} else {
mvx_set_bit(MVX_FORMAT_H264, formats);
mvx_set_bit(MVX_FORMAT_HEVC, formats);
mvx_set_bit(MVX_FORMAT_VP8, formats);
mvx_set_bit(MVX_FORMAT_YUV420_AFBC_8, formats);
mvx_set_bit(MVX_FORMAT_YUV422_AFBC_8, formats);
mvx_set_bit(MVX_FORMAT_YUV420_I420, formats);
mvx_set_bit(MVX_FORMAT_YUV420_NV12, formats);
}
}

View File

@@ -0,0 +1,48 @@
/*
* The confidential and proprietary information contained in this file may
* only be used by a person authorised under and to the extent permitted
* by a subsisting licensing agreement from Arm Technology (China) Co., Ltd.
*
* (C) COPYRIGHT 2021-2021 Arm Technology (China) Co., Ltd.
* ALL RIGHTS RESERVED
*
* This entire notice must be reproduced on all copies of this file
* and copies of this file may only be made by a person if such person is
* permitted to do so under the terms of a subsisting license agreement
* from Arm Technology (China) Co., Ltd.
*
* SPDX-License-Identifier: GPL-2.0-only
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef _MVX_HWREG_V500_H_
#define _MVX_HWREG_V500_H_
/****************************************************************************
* Includes
****************************************************************************/
#include "mvx_if.h"
/****************************************************************************
* Exported functions
****************************************************************************/
void mvx_hwreg_get_formats_v500(enum mvx_direction direction,
uint64_t *formats);
#endif /* _MVX_HWREG_V500_H_ */

View File

@@ -0,0 +1,120 @@
/*
* The confidential and proprietary information contained in this file may
* only be used by a person authorised under and to the extent permitted
* by a subsisting licensing agreement from Arm Technology (China) Co., Ltd.
*
* (C) COPYRIGHT 2021-2021 Arm Technology (China) Co., Ltd.
* ALL RIGHTS RESERVED
*
* This entire notice must be reproduced on all copies of this file
* and copies of this file may only be made by a person if such person is
* permitted to do so under the terms of a subsisting license agreement
* from Arm Technology (China) Co., Ltd.
*
* SPDX-License-Identifier: GPL-2.0-only
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/****************************************************************************
* Includes
****************************************************************************/
#include <linux/io.h>
#include "mvx_bitops.h"
#include "mvx_hwreg_v52_v76.h"
/****************************************************************************
* Exported functions
****************************************************************************/
void mvx_hwreg_get_formats_v52_v76(enum mvx_direction direction,
uint64_t *formats)
{
if (direction == MVX_DIR_INPUT) {
mvx_set_bit(MVX_FORMAT_AVS, formats);
mvx_set_bit(MVX_FORMAT_AVS2, formats);
mvx_set_bit(MVX_FORMAT_H263, formats);
mvx_set_bit(MVX_FORMAT_H264, formats);
mvx_set_bit(MVX_FORMAT_HEVC, formats);
mvx_set_bit(MVX_FORMAT_JPEG, formats);
mvx_set_bit(MVX_FORMAT_MPEG2, formats);
mvx_set_bit(MVX_FORMAT_MPEG4, formats);
mvx_set_bit(MVX_FORMAT_RV, formats);
mvx_set_bit(MVX_FORMAT_VC1, formats);
mvx_set_bit(MVX_FORMAT_VP8, formats);
mvx_set_bit(MVX_FORMAT_VP9, formats);
mvx_set_bit(MVX_FORMAT_AV1, formats);
mvx_set_bit(MVX_FORMAT_YUV420_AFBC_8, formats);
mvx_set_bit(MVX_FORMAT_YUV420_AFBC_10, formats);
mvx_set_bit(MVX_FORMAT_YUV422_AFBC_8, formats);
mvx_set_bit(MVX_FORMAT_YUV422_AFBC_10, formats);
mvx_set_bit(MVX_FORMAT_YUV420_I420, formats);
mvx_set_bit(MVX_FORMAT_YUV420_NV12, formats);
mvx_set_bit(MVX_FORMAT_YUV420_NV21, formats);
mvx_set_bit(MVX_FORMAT_YUV420_P010, formats);
mvx_set_bit(MVX_FORMAT_YUV420_Y0L2, formats);
mvx_set_bit(MVX_FORMAT_YUV420_AQB1, formats);
mvx_set_bit(MVX_FORMAT_YUV422_YUY2, formats);
mvx_set_bit(MVX_FORMAT_YUV422_UYVY, formats);
mvx_set_bit(MVX_FORMAT_YUV422_Y210, formats);
mvx_set_bit(MVX_FORMAT_RGBA_8888, formats);
mvx_set_bit(MVX_FORMAT_BGRA_8888, formats);
mvx_set_bit(MVX_FORMAT_ARGB_8888, formats);
mvx_set_bit(MVX_FORMAT_ABGR_8888, formats);
mvx_set_bit(MVX_FORMAT_RGB_888_3P, formats);
mvx_set_bit(MVX_FORMAT_Y, formats);
mvx_set_bit(MVX_FORMAT_YUV444, formats);
mvx_set_bit(MVX_FORMAT_YUV420_I420_10, formats);
mvx_set_bit(MVX_FORMAT_YUV420_2P_10, formats);
mvx_set_bit(MVX_FORMAT_YUV422_1P_10, formats);
mvx_set_bit(MVX_FORMAT_Y_10, formats);
mvx_set_bit(MVX_FORMAT_YUV444_10, formats);
} else {
mvx_set_bit(MVX_FORMAT_H264, formats);
mvx_set_bit(MVX_FORMAT_HEVC, formats);
mvx_set_bit(MVX_FORMAT_JPEG, formats);
mvx_set_bit(MVX_FORMAT_VP8, formats);
mvx_set_bit(MVX_FORMAT_VP9, formats);
mvx_set_bit(MVX_FORMAT_YUV420_AFBC_8, formats);
mvx_set_bit(MVX_FORMAT_YUV420_AFBC_10, formats);
mvx_set_bit(MVX_FORMAT_YUV422_AFBC_8, formats);
mvx_set_bit(MVX_FORMAT_YUV422_AFBC_10, formats);
mvx_set_bit(MVX_FORMAT_Y_AFBC_8, formats);
mvx_set_bit(MVX_FORMAT_Y_AFBC_10, formats);
mvx_set_bit(MVX_FORMAT_YUV420_I420, formats);
mvx_set_bit(MVX_FORMAT_YUV420_NV12, formats);
mvx_set_bit(MVX_FORMAT_YUV420_NV21, formats);
mvx_set_bit(MVX_FORMAT_YUV420_P010, formats);
mvx_set_bit(MVX_FORMAT_YUV420_Y0L2, formats);
mvx_set_bit(MVX_FORMAT_YUV420_AQB1, formats);
mvx_set_bit(MVX_FORMAT_YUV422_YUY2, formats);
mvx_set_bit(MVX_FORMAT_YUV422_UYVY, formats);
mvx_set_bit(MVX_FORMAT_YUV422_Y210, formats);
mvx_set_bit(MVX_FORMAT_RGB_888, formats);
mvx_set_bit(MVX_FORMAT_BGR_888, formats);
mvx_set_bit(MVX_FORMAT_RGB_888_3P, formats);
mvx_set_bit(MVX_FORMAT_Y, formats);
mvx_set_bit(MVX_FORMAT_Y_10, formats);
mvx_set_bit(MVX_FORMAT_YUV444, formats);
mvx_set_bit(MVX_FORMAT_YUV444_10, formats);
mvx_set_bit(MVX_FORMAT_YUV420_2P_10, formats);
mvx_set_bit(MVX_FORMAT_YUV422_1P_10, formats);
}
}

View File

@@ -0,0 +1,49 @@
/*
* The confidential and proprietary information contained in this file may
* only be used by a person authorised under and to the extent permitted
* by a subsisting licensing agreement from Arm Technology (China) Co., Ltd.
*
* (C) COPYRIGHT 2021-2021 Arm Technology (China) Co., Ltd.
* ALL RIGHTS RESERVED
*
* This entire notice must be reproduced on all copies of this file
* and copies of this file may only be made by a person if such person is
* permitted to do so under the terms of a subsisting license agreement
* from Arm Technology (China) Co., Ltd.
*
* SPDX-License-Identifier: GPL-2.0-only
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef _MVX_HWREG_V52_V76_H_
#define _MVX_HWREG_V52_V76_H_
/****************************************************************************
* Includes
****************************************************************************/
#include "mvx_hwreg.h"
#include "mvx_if.h"
/****************************************************************************
* Exported functions
****************************************************************************/
void mvx_hwreg_get_formats_v52_v76(enum mvx_direction direction,
uint64_t *formats);
#endif /* _MVX_HWREG_V52_V76_H_ */

View File

@@ -0,0 +1,82 @@
/*
* The confidential and proprietary information contained in this file may
* only be used by a person authorised under and to the extent permitted
* by a subsisting licensing agreement from Arm Technology (China) Co., Ltd.
*
* (C) COPYRIGHT 2021-2021 Arm Technology (China) Co., Ltd.
* ALL RIGHTS RESERVED
*
* This entire notice must be reproduced on all copies of this file
* and copies of this file may only be made by a person if such person is
* permitted to do so under the terms of a subsisting license agreement
* from Arm Technology (China) Co., Ltd.
*
* SPDX-License-Identifier: GPL-2.0-only
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/****************************************************************************
* Includes
****************************************************************************/
#include "mvx_bitops.h"
#include "mvx_hwreg_v550.h"
/****************************************************************************
* Exported functions
****************************************************************************/
void mvx_hwreg_get_formats_v550(enum mvx_direction direction,
uint64_t *formats)
{
if (direction == MVX_DIR_INPUT) {
mvx_set_bit(MVX_FORMAT_H263, formats);
mvx_set_bit(MVX_FORMAT_H264, formats);
mvx_set_bit(MVX_FORMAT_HEVC, formats);
mvx_set_bit(MVX_FORMAT_JPEG, formats);
mvx_set_bit(MVX_FORMAT_MPEG2, formats);
mvx_set_bit(MVX_FORMAT_MPEG4, formats);
mvx_set_bit(MVX_FORMAT_RV, formats);
mvx_set_bit(MVX_FORMAT_VC1, formats);
mvx_set_bit(MVX_FORMAT_VP8, formats);
mvx_set_bit(MVX_FORMAT_YUV420_I420, formats);
mvx_set_bit(MVX_FORMAT_YUV420_NV12, formats);
mvx_set_bit(MVX_FORMAT_YUV420_NV21, formats);
mvx_set_bit(MVX_FORMAT_YUV420_P010, formats);
mvx_set_bit(MVX_FORMAT_YUV420_Y0L2, formats);
mvx_set_bit(MVX_FORMAT_YUV420_AQB1, formats);
mvx_set_bit(MVX_FORMAT_YUV422_YUY2, formats);
mvx_set_bit(MVX_FORMAT_YUV422_UYVY, formats);
mvx_set_bit(MVX_FORMAT_YUV422_Y210, formats);
} else {
mvx_set_bit(MVX_FORMAT_H264, formats);
mvx_set_bit(MVX_FORMAT_VP8, formats);
mvx_set_bit(MVX_FORMAT_YUV420_AFBC_8, formats);
mvx_set_bit(MVX_FORMAT_YUV420_AFBC_10, formats);
mvx_set_bit(MVX_FORMAT_YUV422_AFBC_8, formats);
mvx_set_bit(MVX_FORMAT_YUV422_AFBC_10, formats);
mvx_set_bit(MVX_FORMAT_YUV420_I420, formats);
mvx_set_bit(MVX_FORMAT_YUV420_NV12, formats);
mvx_set_bit(MVX_FORMAT_YUV420_NV21, formats);
mvx_set_bit(MVX_FORMAT_YUV420_P010, formats);
mvx_set_bit(MVX_FORMAT_YUV420_Y0L2, formats);
mvx_set_bit(MVX_FORMAT_YUV420_AQB1, formats);
mvx_set_bit(MVX_FORMAT_YUV422_YUY2, formats);
mvx_set_bit(MVX_FORMAT_YUV422_UYVY, formats);
mvx_set_bit(MVX_FORMAT_YUV422_Y210, formats);
}
}

View File

@@ -0,0 +1,48 @@
/*
* The confidential and proprietary information contained in this file may
* only be used by a person authorised under and to the extent permitted
* by a subsisting licensing agreement from Arm Technology (China) Co., Ltd.
*
* (C) COPYRIGHT 2021-2021 Arm Technology (China) Co., Ltd.
* ALL RIGHTS RESERVED
*
* This entire notice must be reproduced on all copies of this file
* and copies of this file may only be made by a person if such person is
* permitted to do so under the terms of a subsisting license agreement
* from Arm Technology (China) Co., Ltd.
*
* SPDX-License-Identifier: GPL-2.0-only
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef _MVX_HWREG_V550_H_
#define _MVX_HWREG_V550_H_
/****************************************************************************
* Includes
****************************************************************************/
#include "mvx_if.h"
/****************************************************************************
* Exported functions
****************************************************************************/
void mvx_hwreg_get_formats_v550(enum mvx_direction direction,
uint64_t *formats);
#endif /* _MVX_HWREG_V550_H_ */

View File

@@ -0,0 +1,95 @@
/*
* The confidential and proprietary information contained in this file may
* only be used by a person authorised under and to the extent permitted
* by a subsisting licensing agreement from Arm Technology (China) Co., Ltd.
*
* (C) COPYRIGHT 2021-2021 Arm Technology (China) Co., Ltd.
* ALL RIGHTS RESERVED
*
* This entire notice must be reproduced on all copies of this file
* and copies of this file may only be made by a person if such person is
* permitted to do so under the terms of a subsisting license agreement
* from Arm Technology (China) Co., Ltd.
*
* SPDX-License-Identifier: GPL-2.0-only
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/****************************************************************************
* Includes
****************************************************************************/
#include <linux/io.h>
#include "mvx_bitops.h"
#include "mvx_hwreg_v61.h"
/****************************************************************************
* Exported functions
****************************************************************************/
void mvx_hwreg_get_formats_v61(enum mvx_direction direction,
uint64_t *formats)
{
if (direction == MVX_DIR_INPUT) {
mvx_set_bit(MVX_FORMAT_H263, formats);
mvx_set_bit(MVX_FORMAT_H264, formats);
mvx_set_bit(MVX_FORMAT_HEVC, formats);
mvx_set_bit(MVX_FORMAT_JPEG, formats);
mvx_set_bit(MVX_FORMAT_MPEG2, formats);
mvx_set_bit(MVX_FORMAT_MPEG4, formats);
mvx_set_bit(MVX_FORMAT_RV, formats);
mvx_set_bit(MVX_FORMAT_VC1, formats);
mvx_set_bit(MVX_FORMAT_VP8, formats);
mvx_set_bit(MVX_FORMAT_VP9, formats);
mvx_set_bit(MVX_FORMAT_YUV420_AFBC_8, formats);
mvx_set_bit(MVX_FORMAT_YUV420_AFBC_10, formats);
mvx_set_bit(MVX_FORMAT_YUV422_AFBC_8, formats);
mvx_set_bit(MVX_FORMAT_YUV422_AFBC_10, formats);
mvx_set_bit(MVX_FORMAT_YUV420_I420, formats);
mvx_set_bit(MVX_FORMAT_YUV420_NV12, formats);
mvx_set_bit(MVX_FORMAT_YUV420_NV21, formats);
mvx_set_bit(MVX_FORMAT_YUV420_P010, formats);
mvx_set_bit(MVX_FORMAT_YUV420_Y0L2, formats);
mvx_set_bit(MVX_FORMAT_YUV420_AQB1, formats);
mvx_set_bit(MVX_FORMAT_YUV422_YUY2, formats);
mvx_set_bit(MVX_FORMAT_YUV422_UYVY, formats);
mvx_set_bit(MVX_FORMAT_YUV422_Y210, formats);
mvx_set_bit(MVX_FORMAT_RGBA_8888, formats);
mvx_set_bit(MVX_FORMAT_BGRA_8888, formats);
mvx_set_bit(MVX_FORMAT_ARGB_8888, formats);
mvx_set_bit(MVX_FORMAT_ABGR_8888, formats);
} else {
mvx_set_bit(MVX_FORMAT_H264, formats);
mvx_set_bit(MVX_FORMAT_HEVC, formats);
mvx_set_bit(MVX_FORMAT_JPEG, formats);
mvx_set_bit(MVX_FORMAT_VP8, formats);
mvx_set_bit(MVX_FORMAT_VP9, formats);
mvx_set_bit(MVX_FORMAT_YUV420_AFBC_8, formats);
mvx_set_bit(MVX_FORMAT_YUV420_AFBC_10, formats);
mvx_set_bit(MVX_FORMAT_YUV422_AFBC_8, formats);
mvx_set_bit(MVX_FORMAT_YUV422_AFBC_10, formats);
mvx_set_bit(MVX_FORMAT_YUV420_I420, formats);
mvx_set_bit(MVX_FORMAT_YUV420_NV12, formats);
mvx_set_bit(MVX_FORMAT_YUV420_NV21, formats);
mvx_set_bit(MVX_FORMAT_YUV420_P010, formats);
mvx_set_bit(MVX_FORMAT_YUV420_Y0L2, formats);
mvx_set_bit(MVX_FORMAT_YUV420_AQB1, formats);
mvx_set_bit(MVX_FORMAT_YUV422_YUY2, formats);
mvx_set_bit(MVX_FORMAT_YUV422_UYVY, formats);
mvx_set_bit(MVX_FORMAT_YUV422_Y210, formats);
}
}

View File

@@ -0,0 +1,49 @@
/*
* The confidential and proprietary information contained in this file may
* only be used by a person authorised under and to the extent permitted
* by a subsisting licensing agreement from Arm Technology (China) Co., Ltd.
*
* (C) COPYRIGHT 2021-2021 Arm Technology (China) Co., Ltd.
* ALL RIGHTS RESERVED
*
* This entire notice must be reproduced on all copies of this file
* and copies of this file may only be made by a person if such person is
* permitted to do so under the terms of a subsisting license agreement
* from Arm Technology (China) Co., Ltd.
*
* SPDX-License-Identifier: GPL-2.0-only
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef _MVX_HWREG_V61_H_
#define _MVX_HWREG_V61_H_
/****************************************************************************
* Includes
****************************************************************************/
#include "mvx_hwreg.h"
#include "mvx_if.h"
/****************************************************************************
* Exported functions
****************************************************************************/
void mvx_hwreg_get_formats_v61(enum mvx_direction direction,
uint64_t *formats);
#endif /* _MVX_HWREG_V61_H_ */

View File

@@ -0,0 +1,356 @@
/*
* The confidential and proprietary information contained in this file may
* only be used by a person authorised under and to the extent permitted
* by a subsisting licensing agreement from Arm Technology (China) Co., Ltd.
*
* (C) COPYRIGHT 2021-2021 Arm Technology (China) Co., Ltd.
* ALL RIGHTS RESERVED
*
* This entire notice must be reproduced on all copies of this file
* and copies of this file may only be made by a person if such person is
* permitted to do so under the terms of a subsisting license agreement
* from Arm Technology (China) Co., Ltd.
*
* SPDX-License-Identifier: GPL-2.0-only
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/****************************************************************************
* Includes
****************************************************************************/
#include <linux/device.h>
#include <linux/of.h>
#include <linux/module.h>
#include "mvx_if.h"
#include "mvx_hwreg.h"
#include "mvx_lsid.h"
#include "mvx_log_group.h"
#include "mvx_session.h"
/*
* In CIX SKY1, bus_attributes must be 0x33, especially bus_attribute[0] ARCACHE
* must be 0x3(Normal Non-cacheable Bufferable). Otherwise, VPU load firmware
* may failed or occurs other unexpected crash.
*
* Todo: remove this debug param in formal release.
*/
static uint bus_attributes[4] = {0x33, 0x22, 0x33, 0x33};
module_param_array(bus_attributes, uint, NULL, 0660);
MODULE_PARM_DESC(bus_attributes, "Bus attributes.");
/****************************************************************************
* Private functions
****************************************************************************/
static bool is_alloc(struct mvx_lsid *lsid)
{
uint32_t alloc;
alloc = mvx_hwreg_read_lsid(lsid->hwreg, lsid->lsid,
MVX_HWREG_ALLOC);
return alloc != MVE_ALLOC_FREE;
}
static uint32_t get_core_lsid(uint32_t reg,
unsigned int core)
{
return (reg >> (MVE_CORELSID_LSID_BITS * core)) &
MVX_CORELSID_LSID_MASK;
}
static uint32_t get_jobqueue_job(uint32_t reg,
unsigned int nr)
{
return (reg >> (MVE_JOBQUEUE_JOB_BITS * nr)) & MVE_JOBQUEUE_JOB_MASK;
}
static uint32_t set_jobqueue_job(uint32_t reg,
unsigned int nr,
uint32_t job)
{
reg &= ~(MVE_JOBQUEUE_JOB_MASK << (nr * MVE_JOBQUEUE_JOB_BITS));
reg |= job << (MVE_JOBQUEUE_JOB_BITS * nr);
return reg;
}
static uint32_t get_jobqueue_lsid(uint32_t reg,
unsigned int nr)
{
return (reg >> (MVE_JOBQUEUE_JOB_BITS * nr + MVE_JOBQUEUE_LSID_SHIFT)) &
MVE_JOBQUEUE_LSID_MASK;
}
static uint32_t set_lsid_ncores(uint32_t reg,
unsigned int nr,
unsigned int lsid,
unsigned int ncores)
{
reg &= ~(MVE_JOBQUEUE_JOB_MASK << (nr * MVE_JOBQUEUE_JOB_BITS));
reg |= ((lsid << MVE_JOBQUEUE_LSID_SHIFT) |
((ncores - 1) << MVE_JOBQUEUE_NCORES_SHIFT)) <<
(nr * MVE_JOBQUEUE_JOB_BITS);
return reg;
}
/****************************************************************************
* Exported functions
****************************************************************************/
int mvx_lsid_construct(struct mvx_lsid *lsid,
struct device *dev,
struct mvx_hwreg *hwreg,
unsigned int id)
{
lsid->dev = dev;
lsid->hwreg = hwreg;
lsid->session = NULL;
lsid->lsid = id;
return 0;
}
void mvx_lsid_destruct(struct mvx_lsid *lsid)
{}
int mvx_lsid_map(struct mvx_lsid *lsid,
struct mvx_lsid_pcb *pcb)
{
struct mvx_hwreg *hwreg = lsid->hwreg;
uint32_t alloc;
uint32_t busattr[4];
int i;
int ret;
/* Check that the LSID is not already allocated. */
if (is_alloc(lsid)) {
MVX_LOG_PRINT(&mvx_log_dev, MVX_LOG_WARNING,
"Failed to map session to LSID. LSID already allocated. lsid=%u.",
lsid->lsid);
return -EFAULT;
}
/* Allocate LSID. */
alloc = pcb->nprot == 0 ? MVE_ALLOC_PROTECTED : MVE_ALLOC_NON_PROTECTED;
mvx_hwreg_write_lsid(hwreg, lsid->lsid, MVX_HWREG_ALLOC, alloc);
mvx_hwreg_write_lsid(hwreg, lsid->lsid, MVX_HWREG_TERMINATE, 1);
do {
ret = mvx_hwreg_read_lsid(hwreg, lsid->lsid,
MVX_HWREG_TERMINATE);
} while (ret != 0);
/* Configure number of cores to use and which to cores to disable. */
mvx_hwreg_write_lsid(hwreg, lsid->lsid, MVX_HWREG_CTRL,
pcb->ctrl);
/* Configure MMU L0 entry and flush MMU tables. */
mvx_hwreg_write_lsid(hwreg, lsid->lsid, MVX_HWREG_MMU_CTRL,
pcb->mmu_ctrl);
mvx_hwreg_write_lsid(hwreg, lsid->lsid, MVX_HWREG_FLUSH_ALL, 0);
if (device_property_read_u32_array(lsid->dev, "busattr", busattr,
ARRAY_SIZE(busattr))) {
MVX_LOG_PRINT(&mvx_log_dev, MVX_LOG_DEBUG,
"busattr in of_node is not available.");
/* We apply module params in this case for debug purpose. */
memcpy(busattr, bus_attributes, sizeof(busattr));
}
for (i = 0; i < ARRAY_SIZE(busattr); i++)
MVX_LOG_PRINT(&mvx_log_dev, MVX_LOG_VERBOSE,
"busattr[%d] = 0x%x.", i, busattr[i]);
mvx_hwreg_write_lsid(hwreg, lsid->lsid, MVX_HWREG_BUSATTR_0,
busattr[0]);
mvx_hwreg_write_lsid(hwreg, lsid->lsid, MVX_HWREG_BUSATTR_1,
busattr[1]);
mvx_hwreg_write_lsid(hwreg, lsid->lsid, MVX_HWREG_BUSATTR_2,
busattr[2]);
mvx_hwreg_write_lsid(hwreg, lsid->lsid, MVX_HWREG_BUSATTR_3,
busattr[3]);
/* Restore interrupt registers. */
mvx_hwreg_write_lsid(hwreg, lsid->lsid, MVX_HWREG_LIRQVE, 0);
mvx_hwreg_write_lsid(hwreg, lsid->lsid, MVX_HWREG_IRQHOST,
pcb->irqhost);
/*
* Make sure all register writes have completed before scheduling is
* enabled.
*/
wmb();
/* Enable scheduling. */
mvx_hwreg_write_lsid(hwreg, lsid->lsid, MVX_HWREG_SCHED, 1);
return 0;
}
void mvx_lsid_unmap(struct mvx_lsid *lsid,
struct mvx_lsid_pcb *pcb)
{
struct mvx_hwreg *hwreg = lsid->hwreg;
if (!is_alloc(lsid)) {
MVX_LOG_PRINT(&mvx_log_dev, MVX_LOG_WARNING,
"LSID was not allocated. lsid=%u.",
lsid->lsid);
return;
}
/* Disable scheduling. */
mvx_hwreg_write_lsid(hwreg, lsid->lsid, MVX_HWREG_SCHED, 0);
/* Store registers in process control block. */
pcb->ctrl = mvx_hwreg_read_lsid(hwreg, lsid->lsid, MVX_HWREG_CTRL);
pcb->mmu_ctrl = mvx_hwreg_read_lsid(hwreg, lsid->lsid,
MVX_HWREG_MMU_CTRL);
pcb->irqhost = mvx_hwreg_read_lsid(hwreg, lsid->lsid,
MVX_HWREG_IRQHOST);
pcb->nprot = mvx_hwreg_read_lsid(hwreg, lsid->lsid, MVX_HWREG_NPROT);
/* Deallocate LSID. */
mvx_hwreg_write_lsid(hwreg, lsid->lsid, MVX_HWREG_ALLOC,
MVE_ALLOC_FREE);
}
int mvx_lsid_jobqueue_add(struct mvx_lsid *lsid,
unsigned int ncores)
{
struct mvx_hwreg *hwreg = lsid->hwreg;
uint32_t jobqueue;
int i;
/* Disable scheduling. */
mvx_hwreg_write(hwreg, MVX_HWREG_ENABLE, 0);
jobqueue = mvx_hwreg_read(hwreg, MVX_HWREG_JOBQUEUE);
/* Search if the LSID is already in the job queue. */
for (i = 0; i < MVE_JOBQUEUE_NJOBS; i++)
if (get_jobqueue_lsid(jobqueue, i) == lsid->lsid)
goto jobqueue_enable;
/* Search for a free slot in the job queue. */
for (i = 0; i < MVE_JOBQUEUE_NJOBS; i++)
if (get_jobqueue_lsid(jobqueue, i) ==
MVE_JOBQUEUE_JOB_INVALID) {
jobqueue = set_lsid_ncores(jobqueue, i, lsid->lsid,
ncores);
mvx_hwreg_write(hwreg, MVX_HWREG_JOBQUEUE, jobqueue);
break;
}
jobqueue_enable:
/* Reenable scheduling. */
mvx_hwreg_write(hwreg, MVX_HWREG_ENABLE, 1);
return i < MVE_JOBQUEUE_NJOBS ? 0 : -EAGAIN;
}
void mvx_lsid_send_irq(struct mvx_lsid *lsid)
{
struct mvx_hwreg *hwreg = lsid->hwreg;
mvx_hwreg_write_lsid(hwreg, lsid->lsid, MVX_HWREG_IRQHOST, 1);
}
void mvx_lsid_trigger_irqve(struct mvx_lsid *lsid)
{
struct mvx_hwreg *hwreg = lsid->hwreg;
mvx_hwreg_write_lsid(hwreg, lsid->lsid, MVX_HWREG_LIRQVE, 1);
}
void mvx_lsid_flush_mmu(struct mvx_lsid *lsid)
{
struct mvx_hwreg *hwreg = lsid->hwreg;
mvx_hwreg_write_lsid(hwreg, lsid->lsid, MVX_HWREG_FLUSH_ALL, 0);
}
void mvx_lsid_terminate(struct mvx_lsid *lsid)
{
struct mvx_hwreg *hwreg = lsid->hwreg;
uint32_t ret;
mvx_hwreg_write_lsid(hwreg, lsid->lsid, MVX_HWREG_TERMINATE, 1);
ret = wait_event_interruptible_timeout(hwreg->wait_queue,
mvx_hwreg_read_lsid(hwreg, lsid->lsid, MVX_HWREG_TERMINATE) == 0,
msecs_to_jiffies(MVX_HWREG_TERMINATE_TIMEOUT));
if (!ret)
MVX_LOG_PRINT(&mvx_log_dev, MVX_LOG_ERROR,
"Wait LSID[%d] termiate timeout", lsid->lsid);
}
void mvx_lsid_jobqueue_remove(struct mvx_lsid *lsid)
{
struct mvx_hwreg *hwreg = lsid->hwreg;
uint32_t jobqueue;
int i;
int j;
/* Disable scheduling. */
mvx_hwreg_write(hwreg, MVX_HWREG_ENABLE, 0);
jobqueue = mvx_hwreg_read(hwreg, MVX_HWREG_JOBQUEUE);
/* Copy job entries that do not match the LSID to be removed. */
for (i = 0, j = 0; i < MVE_JOBQUEUE_NJOBS; i++)
if (get_jobqueue_lsid(jobqueue, i) != lsid->lsid)
jobqueue = set_jobqueue_job(
jobqueue, j++, get_jobqueue_job(jobqueue, i));
/* Blank out remaining job entries. */
for (; j < MVE_JOBQUEUE_NJOBS; j++)
jobqueue = set_lsid_ncores(jobqueue, j,
MVE_JOBQUEUE_JOB_INVALID, 0);
mvx_hwreg_write(hwreg, MVX_HWREG_JOBQUEUE, jobqueue);
/* Reenable scheduling. */
mvx_hwreg_write(hwreg, MVX_HWREG_ENABLE, 1);
}
bool mvx_lsid_idle(struct mvx_lsid *lsid)
{
struct mvx_hwreg *hwreg = lsid->hwreg;
uint32_t jobqueue;
uint32_t corelsid;
uint32_t ncores;
uint32_t i;
jobqueue = mvx_hwreg_read(hwreg, MVX_HWREG_JOBQUEUE);
corelsid = mvx_hwreg_read(hwreg, MVX_HWREG_CORELSID);
ncores = mvx_hwreg_read(hwreg, MVX_HWREG_NCORES);
/* Check if LSID is found in job queue. */
for (i = 0; i < MVE_JOBQUEUE_NJOBS; i++)
if (get_jobqueue_lsid(jobqueue, i) == lsid->lsid)
return false;
/* Check if LSID is found in core lsid. */
for (i = 0; i < ncores; i++)
if (get_core_lsid(corelsid, i) == lsid->lsid)
return false;
return true;
}

View File

@@ -0,0 +1,172 @@
/*
* The confidential and proprietary information contained in this file may
* only be used by a person authorised under and to the extent permitted
* by a subsisting licensing agreement from Arm Technology (China) Co., Ltd.
*
* (C) COPYRIGHT 2021-2021 Arm Technology (China) Co., Ltd.
* ALL RIGHTS RESERVED
*
* This entire notice must be reproduced on all copies of this file
* and copies of this file may only be made by a person if such person is
* permitted to do so under the terms of a subsisting license agreement
* from Arm Technology (China) Co., Ltd.
*
* SPDX-License-Identifier: GPL-2.0-only
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef _MVX_LSID_H_
#define _MVX_LSID_H_
/****************************************************************************
* Includes
****************************************************************************/
#include <linux/types.h>
/****************************************************************************
* Defines
****************************************************************************/
#define MVX_LSID_MAX 4
/****************************************************************************
* Types
****************************************************************************/
struct device;
struct mvx_hwreg;
struct mvx_sched_session;
/**
* struct mvx_lsid_pcb - LSID process control block.
*
* This structure is used to store the register map when a session is unmapped
* from a LSID, so it can be restored again when the session is remapped.
*/
struct mvx_lsid_pcb {
uint32_t ctrl;
uint32_t mmu_ctrl;
uint32_t irqhost;
uint32_t nprot;
};
/**
* struct mvx_lsid - LSID class.
*/
struct mvx_lsid {
struct device *dev;
struct mvx_hwreg *hwreg;
struct mvx_sched_session *session;
unsigned int lsid;
};
/****************************************************************************
* Exported functions
****************************************************************************/
/**
* mvx_lsid_construct() - Construct the LSID object.
* @lsid: Pointer to LSID object.
* @dev: Pointer to device.
* @hwreg: Pointer to hwreg object.
* @id: LSID number.
*
* Return: 0 on success, else error code.
*/
int mvx_lsid_construct(struct mvx_lsid *lsid,
struct device *dev,
struct mvx_hwreg *hwreg,
unsigned int id);
/**
* mvx_lsid_destruct() - Destruct the LSID object.
* @lsid: Pointer to LSID object.
*/
void mvx_lsid_destruct(struct mvx_lsid *lsid);
/**
* mvx_lsid_map() - Map a session to this LSID.
* @lsid: Pointer to LSID object.
* @pcb: Process control block to be restored.
*
* Return: 0 on success, else error code.
*/
int mvx_lsid_map(struct mvx_lsid *lsid,
struct mvx_lsid_pcb *pcb);
/**
* mvx_lsid_unmap() - Unmap session from LSID.
* @lsid: Pointer to LSID object.
* @pcb: Process control block where the registers are stored.
*
* A LSID must not be unmapped if it is present in the job queue or core LSID.
* It is the responsibility of the scheduler to guarantee that the LSID is idle
* before it is unmapped.
*/
void mvx_lsid_unmap(struct mvx_lsid *lsid,
struct mvx_lsid_pcb *pcb);
/**
* mvx_lsid_jobqueue_add() - Add LSID to job queue.
* @lsid: Pointer to LSID object.
* @ncores: Number of cores to request.
*
* Return: 0 on success, else error code.
*/
int mvx_lsid_jobqueue_add(struct mvx_lsid *lsid,
unsigned int ncores);
/**
* mvx_lsid_send_irq() - Send IRQ to firmware.
* @lsid: Pointer to LSID object.
*/
void mvx_lsid_send_irq(struct mvx_lsid *lsid);
/**
* mvx_lsid_trigger_irqve() - Send trigger IRQVE.
* @lsid: Pointer to LSID object.
*/
void mvx_lsid_trigger_irqve(struct mvx_lsid *lsid);
/**
* mvx_lsid_flush_mmu() - Flush MMU tables.
* @lsid: Pointer to LSID object.
*/
void mvx_lsid_flush_mmu(struct mvx_lsid *lsid);
/**
* mvx_lsid_terminate() - Terminate the LSID.
* @lsid: Pointer to LSID object.
*/
void mvx_lsid_terminate(struct mvx_lsid *lsid);
/**
* mvx_lsid_jobqueue_remove() - Remove LSID from job queue.
* @lsid: Pointer to LSID object.
*/
void mvx_lsid_jobqueue_remove(struct mvx_lsid *lsid);
/**
* mvx_lsid_idle() - Check if LSID is idle.
* @lsid: Pointer to LSID object.
*
* Return: true if LSID is idle, else false.
*/
bool mvx_lsid_idle(struct mvx_lsid *lsid);
#endif /* _MVX_LSID_H_ */

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More