Initial commit: Linux kernel 4.19 for Unplugged OS

This commit is contained in:
ziv committed 2025-10-06 13:52:42 +00:00
commit d30235b04c
80519 files changed
+35800681

No files matched your search

@@ -0,0 +1,36 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# 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.
#
ifeq ($(CONFIG_MTK_ION),y)
ccflags-y += -I$(srctree)/drivers/staging/android/mtk_ion/
ccflags-y += -I$(srctree)/drivers/staging/android/mtk_ion/mtk/
else
ccflags-$(CONFIG_ION) += -I$(srctree)/drivers/staging/android/aosp_ion/
endif
ccflags-y += -I$(srctree)/drivers/misc/mediatek/m4u/$(MTK_PLATFORM)/
ccflags-y += -I$(srctree)/drivers/misc/mediatek/include/mt-plat
ccflags-y += -I$(srctree)/drivers/misc/mediatek/ccu/src/$(MTK_PLATFORM)/
ccflags-y += -I$(srctree)/drivers/misc/mediatek/ccu/src/$(MTK_PLATFORM)/ccu_ext_interface/
ccflags-y += -I$(srctree)/drivers/i2c/busses
ccflags-y += -I$(srctree)/drivers/iommu/
ccflags-y += -I$(srctree)/drivers/misc/mediatek/imgsensor/inc
ccflags-y += -I$(srctree)/drivers/misc/mediatek/smi/
ccflags-y += -I$(srctree)/drivers/misc/mediatek/mmdvfs/
#$(warning $(subdir-ccflags-y))
#obj-$(CONFIG_MTK_VPU) += ccu_drv.o ccu_algo.o ccu_dbg.o
obj-y += ccu_drv.o ccu_n3d_a.o ccu_i2c.o
+254
View File
@@ -0,0 +1,254 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2016 MediaTek Inc.
*/
#ifndef __CCU_CMN_H__
#define __CCU_CMN_H__
#include <linux/wait.h>
#include <linux/seq_file.h>
#include <linux/interrupt.h>
#include "ccu_drv.h"
#define CCU_I2C_DMA_BUF_SIZE (4*PAGE_SIZE)
/* Common Structure */
enum ccu_req_type_e {
CCU_IRQ_TYPE_XXX,
CCU_IRQ_NUM_TYPES
};
struct ccu_device_s {
struct proc_dir_entry *proc_dir;
struct device *dev;
struct dentry *debug_root;
void __iomem *ccu_base;
void __iomem *camsys_base;
void __iomem *bin_base;
void __iomem *dmem_base;
void __iomem *pmem_base;
void __iomem *ddrmem_base;
unsigned int irq_num;
struct mutex user_mutex;
struct mutex ion_client_mutex;
struct mutex dev_mutex;
struct mutex clk_mutex;
u8 *i2c_dma_vaddr;
dma_addr_t i2c_dma_paddr;
uint32_t i2c_dma_mva;
/* list of vlist_type(ccu_user_t) */
struct list_head user_list;
/* notify enque thread */
wait_queue_head_t cmd_wait;
};
struct ccu_user_s {
pid_t open_pid;
pid_t open_tgid;
uint32_t id;
/* to enque/deque must have mutex protection */
struct mutex data_mutex;
bool running;
bool flush;
/* list of vlist_type(ccu_cmd_st) */
struct list_head enque_ccu_cmd_list;
struct list_head deque_ccu_cmd_list;
wait_queue_head_t deque_wait;
};
/*type must be struct*/
/*#define DECLARE_VLIST(type) \*/
/*typedef struct { \*/
/*type node; \*/
/*struct list_head link; \*/
/*} type ## _list*/
/*
* vlist_node_of - get the pointer to the node which has specific vlist
* @ptr: the pointer to struct list_head
* @type: the type of list node
*/
#define vlist_node_of(ptr, type) ({ \
const struct list_head *__mptr = (ptr); \
(type *)((char *)__mptr - offsetof(type ## _list, link)); })
/*
* vlist_link - get the pointer to struct list_head
* @ptr: the pointer to struct vlist
* @type: the type of list node
*/
#define vlist_link(ptr, type) (&((type ## _list *)ptr)->link)
/*
* vlist_type - get the type of struct vlist
* @type: the type of list node
*/
#define vlist_type(type) type ## _list
/*
* vlist_node - get the pointer to the node of vlist
* @ptr: the pointer to struct vlist
* @type: the type of list node
*/
#define vlist_node(ptr, type) ((type *) ptr)
/*typedef struct work_struct work_struct_t;*/
/*DECLARE_VLIST(work_struct_t);*/
/*DECLARE_VLIST(struct ccu_user_s);*/
struct ccu_user_s_list {
struct ccu_user_s node;
struct list_head link;
};
/*DECLARE_VLIST(struct ccu_cmd_s);*/
struct ccu_cmd_s_list {
struct ccu_cmd_s node;
struct list_head link;
};
/* ================= define in ccu_hw.c =================== */
/**
* ccu_init_hw - init the procedure related to hw, include irq
* register and enque thread
* @device: the pointer of ccu_device.
*/
int ccu_init_hw(struct ccu_device_s *device);
/**
* ccu_uninit_hw - close resources related to hw module
*/
int ccu_uninit_hw(struct ccu_device_s *device);
/**
* ccu_mmap_hw - mmap kernel memory to user
*/
int ccu_mmap_hw(struct file *filp, struct vm_area_struct *vma);
/**
* ccu_power - config ccu power.
* @s: the pointer to power relative settings.
*/
int ccu_power(struct ccu_power_s *power);
/**
* ccu_force_powerdown - force CCU to stop & shutdown
*/
int ccu_force_powerdown(void);
/**
* ccu_load_bin - load ccu dm/pm binary.
*/
int ccu_load_bin(struct ccu_device_s *device, struct ccu_bin_info_s *bin_info);
int ccu_sw_hw_reset(void);
/**
* ccu_run - start running ccu .
*/
int ccu_run(struct ccu_run_s *info);
/**
* ccu_irq - interrupt wait.
* @s: wait mode.
*/
int ccu_waitirq(struct CCU_WAIT_IRQ_STRUCT *WaitIrq);
int ccu_AFwaitirq(struct CCU_WAIT_IRQ_STRUCT *WaitIrq, int sensoridx);
/**
* ccu_irq - interrupt wait.
* @s: wait mode.
*/
int ccu_flushLog(int argc, int *argv);
int ccu_memcpy(void *dest, void *src, int length);
int ccu_memclr(void *dest, int length);
int ccu_read_struct_size(uint32_t *structSizes, uint32_t structCnt);
void ccu_print_reg(uint32_t *Reg);
void ccu_print_sram_log(char *sram_log);
int ccu_read_data(uint32_t *buf, uint32_t ccu_da, uint32_t size);
int ccu_query_power_status(void);
/* ================ define in ccu_drv.c ================ */
/**
* ccu_create_user - create ccu user, and add to user list
* @ruser: return the created user.
*/
int ccu_create_user(struct ccu_user_s **ruser);
/**
* ccu_delete_user - delete ccu user, and remove it from user list
* @user: the pointer to user.
*/
int ccu_delete_user(struct ccu_user_s *user);
int ccu_lock_ion_client_mutex(void);
int ccu_unlock_ion_client_mutex(void);
/**
* ccu_clock_enable - Set CCU clock on
*/
int ccu_clock_enable(void);
/**
* ccu_clock_disable - Set CCU clock off
*/
void ccu_clock_disable(void);
/* LOG & AEE */
#define CCU_TAG "[ccu]"
#define LOG_DBG_MUST(format, args...) \
pr_debug(CCU_TAG "[%s] " format, __func__, ##args)
#define LOG_INF_MUST(format, args...) \
pr_info(CCU_TAG "[%s] " format, __func__, ##args)
#define LOG_DBG(format, args...)
#define LOG_INF(format, args...)
#define LOG_WARN(format, args...) \
pr##_##warn(CCU_TAG "[%s] " format, __func__, ##args)
#define LOG_ERR(format, args...) \
pr##_##err(CCU_TAG "[%s] " format, __func__, ##args)
#define LOG_DERR(device, format, args...) \
dev##_##err(device, CCU_TAG "[%s] " format, __func__, ##args)
#define ccu_print_seq(seq_file, fmt, args...) \
do {\
if (seq_file)\
seq_printf(seq_file, fmt, ##args);\
else\
pr_debug(fmt, ##args);\
} while (0)
#define ccu_error(format, args...) \
do {\
LOG_ERR(CCU_TAG " error:"format, ##args); \
aee_kernel_exception("CCU", "[CCU] error:"format, ##args); \
} while (0)
#define ccu_aee(format, args...) \
do {\
char ccu_name[100];\
snprintf(ccu_name, 100, CCU_TAG format, ##args); \
aee_kernel_warning_api(__FILE__, __LINE__, \
DB_OPT_MMPROFILE_BUFFER | DB_OPT_DUMP_DISPLAY, \
ccu_name, CCU_TAG "error" format, ##args); \
LOG_ERR(CCU_TAG " error:" format, ##args); \
} while (0)
#endif
File diff suppressed because it is too large. Load diff
+374
View File
@@ -0,0 +1,374 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2016 MediaTek Inc.
*/
#ifndef __CCU_DRV_H__
#define __CCU_DRV_H__
#include <linux/types.h>
#include <linux/ioctl.h>
#include "ccu_mailbox_extif.h"
#include "kd_camera_feature.h"/*for sensoridx enum*/
#ifdef CONFIG_COMPAT
/*64 bit*/
#include <linux/fs.h>
#include <linux/compat.h>
#endif
/*---------------------------------------------------------------------------*/
/* CCU IRQ */
/*---------------------------------------------------------------------------*/
#define IRQ_USER_NUM_MAX 32
#define SUPPORT_MAX_IRQ 32
enum CCU_IRQ_CLEAR_ENUM {
CCU_IRQ_CLEAR_NONE, /* non-clear wait, clear after wait */
CCU_IRQ_CLEAR_WAIT, /* clear wait, clear before and after wait */
CCU_IRQ_CLEAR_STATUS, /* clear specific status only */
CCU_IRQ_CLEAR_ALL /* clear all status */
};
enum CCU_IRQ_TYPE_ENUM {
CCU_IRQ_TYPE_INT_CCU_ST,
CCU_IRQ_TYPE_INT_CCU_A_ST,
CCU_IRQ_TYPE_INT_CCU_B_ST,
CCU_IRQ_TYPE_AMOUNT
};
enum CCU_ST_ENUM {
CCU_SIGNAL_INT = 0, CCU_DMA_INT, CCU_IRQ_ST_AMOUNT
};
struct CCU_IRQ_TIME_STRUCT {
unsigned int tLastSig_sec;
/* time stamp of the latest occurring signal */
unsigned int tLastSig_usec;
/* time stamp of the latest occurring signal */
unsigned int tMark2WaitSig_sec;
/* time period from marking a signal to user try to wait and get the signal */
unsigned int tMark2WaitSig_usec;
/* time period from marking a signal to user try to wait and get the signal */
unsigned int tLastSig2GetSig_sec;
/* time period from latest signal to user try to wait and get the signal */
unsigned int tLastSig2GetSig_usec;
/* time period from latest signal to user try to wait and get the signal */
int passedbySigcnt; /* the count for the signal passed by */
};
struct CCU_WAIT_IRQ_ST {
enum CCU_IRQ_CLEAR_ENUM Clear;
enum CCU_ST_ENUM St_type;
unsigned int Status;
int UserKey; /* user key for doing interrupt operation */
unsigned int Timeout;
struct CCU_IRQ_TIME_STRUCT TimeInfo;
};
struct CCU_REGISTER_USERKEY_STRUCT {
int userKey;
char userName[32];
};
struct CCU_WAIT_IRQ_STRUCT {
enum CCU_IRQ_TYPE_ENUM Type;
unsigned int bDumpReg;
struct CCU_WAIT_IRQ_ST EventInfo;
};
struct CCU_CLEAR_IRQ_ST {
int UserKey; /* user key for doing interrupt operation */
enum CCU_ST_ENUM St_type;
unsigned int Status;
};
struct CCU_CLEAR_IRQ_STRUCT {
enum CCU_IRQ_TYPE_ENUM Type;
struct CCU_CLEAR_IRQ_ST EventInfo;
};
struct CCU_REG_STRUCT {
unsigned int module;
unsigned int Addr; /* register's addr */
unsigned int Val; /* register's value */
};
struct CCU_REG_IO_STRUCT {
struct CCU_REG_STRUCT *pData; /* pointer to struct CCU_REG_STRUCT */
unsigned int Count; /* count */
};
struct CCU_IRQ_INFO_STRUCT {
/* Add an extra index for status type in Ever -> signal or dma */
unsigned int Status[CCU_IRQ_TYPE_AMOUNT][CCU_IRQ_ST_AMOUNT][IRQ_USER_NUM_MAX];
unsigned int Mask[CCU_IRQ_TYPE_AMOUNT][CCU_IRQ_ST_AMOUNT];
unsigned int ErrMask[CCU_IRQ_TYPE_AMOUNT][CCU_IRQ_ST_AMOUNT];
signed int WarnMask[CCU_IRQ_TYPE_AMOUNT][CCU_IRQ_ST_AMOUNT];
/* flag for indicating that user do mark for a interrupt or not */
unsigned int MarkedFlag[CCU_IRQ_TYPE_AMOUNT][CCU_IRQ_ST_AMOUNT][IRQ_USER_NUM_MAX];
/* time for marking a specific interrupt */
unsigned int MarkedTime_sec[CCU_IRQ_TYPE_AMOUNT][32][IRQ_USER_NUM_MAX];
/* time for marking a specific interrupt */
unsigned int MarkedTime_usec[CCU_IRQ_TYPE_AMOUNT][32][IRQ_USER_NUM_MAX];
/* number of a specific signal that passed by */
signed int PassedBySigCnt[CCU_IRQ_TYPE_AMOUNT][32][IRQ_USER_NUM_MAX];
/* */
unsigned int LastestSigTime_sec[CCU_IRQ_TYPE_AMOUNT][32];
/* latest time for each interrupt */
unsigned int LastestSigTime_usec[CCU_IRQ_TYPE_AMOUNT][32];
/* latest time for each interrupt */
};
#define CCU_ISR_MAX_NUM 32
#define INT_ERR_WARN_TIMER_THREAS 1000
#define INT_ERR_WARN_MAX_TIME 3
struct CCU_IRQ_ERR_WAN_CNT_STRUCT {
unsigned int m_err_int_cnt[CCU_IRQ_TYPE_AMOUNT][CCU_ISR_MAX_NUM]; /* cnt for each err int # */
unsigned int m_warn_int_cnt[CCU_IRQ_TYPE_AMOUNT][CCU_ISR_MAX_NUM]; /* cnt for each warning int # */
unsigned int m_err_int_mark[CCU_IRQ_TYPE_AMOUNT]; /* mark for err int, where its cnt > threshold */
unsigned int m_warn_int_mark[CCU_IRQ_TYPE_AMOUNT]; /* mark for warn int, where its cnt > threshold */
unsigned long m_int_usec[CCU_IRQ_TYPE_AMOUNT];
};
#define CCU_BUF_SIZE (4096)
#define CCU_BUF_SIZE_WRITE 1024
#define CCU_BUF_WRITE_AMOUNT 6
enum CCU_BUF_STATUS_ENUM {
CCU_BUF_STATUS_EMPTY,
CCU_BUF_STATUS_HOLD,
CCU_BUF_STATUS_READY
};
struct CCU_BUF_STRUCT {
enum CCU_BUF_STATUS_ENUM Status;
unsigned int Size;
unsigned char *pData;
};
struct CCU_BUF_INFO_STRUCT {
struct CCU_BUF_STRUCT Read;
struct CCU_BUF_STRUCT Write[CCU_BUF_WRITE_AMOUNT];
};
struct CCU_TIME_LOG_STRUCT {
unsigned int Vd;
unsigned int Expdone;
unsigned int WorkQueueVd;
unsigned int WorkQueueExpdone;
unsigned int TaskletVd;
unsigned int TaskletExpdone;
};
#ifdef MTK_VPU_KERNEL
struct CCU_INFO_STRUCT {
spinlock_t SpinLockCcuRef;
spinlock_t SpinLockCcu;
spinlock_t SpinLockIrq[CCU_IRQ_TYPE_AMOUNT];
spinlock_t SpinLockIrqCnt[CCU_IRQ_TYPE_AMOUNT];
spinlock_t SpinLockRTBC;
spinlock_t SpinLockClock;
spinlock_t SpinLockI2cPower;
unsigned int IsCcuPoweredOn;
wait_queue_head_t WaitQueueHead;
wait_queue_head_t AFWaitQueueHead[IMGSENSOR_SENSOR_IDX_MAX_NUM];
wait_queue_head_t WaitQHeadList[SUPPORT_MAX_IRQ];
unsigned int UserCount;
unsigned int DebugMask;
signed int IrqNum;
struct CCU_IRQ_INFO_STRUCT IrqInfo;
struct CCU_IRQ_ERR_WAN_CNT_STRUCT IrqCntInfo;
struct CCU_BUF_INFO_STRUCT BufInfo;
struct CCU_TIME_LOG_STRUCT TimeLog;
};
#endif
/*---------------------------------------------------------------------------*/
/* CCU working buffer */
/*---------------------------------------------------------------------------*/
#define SIZE_32BYTE (32)
#define SIZE_1MB (1024*1024)
#define SIZE_1MB_PWR2PAGE (8)
#define MAX_I2CBUF_NUM 1
#define MAX_MAILBOX_NUM 2
#define MAX_LOG_BUF_NUM 2
#define MAILBOX_SEND 0
#define MAILBOX_GET 1
struct ccu_working_buffer_s {
uint8_t *va_pool;
uint32_t mva_pool;
uint32_t sz_pool;
uint8_t *va_i2c; /* i2c buffer mode */
uint32_t mva_i2c;
uint32_t sz_i2c;
uint8_t *va_mb[MAX_MAILBOX_NUM]; /* mailbox */
uint32_t mva_mb[MAX_MAILBOX_NUM];
uint32_t sz_mb[MAX_MAILBOX_NUM];
char *va_log[MAX_LOG_BUF_NUM]; /* log buffer */
uint32_t mva_log[MAX_LOG_BUF_NUM];
uint32_t sz_log[MAX_LOG_BUF_NUM];
int32_t fd_log[MAX_LOG_BUF_NUM];
};
#ifdef CONFIG_COMPAT
struct compat_ccu_working_buffer_s {
compat_uptr_t va_pool;
uint32_t mva_pool;
uint32_t sz_pool;
compat_uptr_t va_i2c; /* i2c buffer mode */
uint32_t mva_i2c;
uint32_t sz_i2c;
compat_uptr_t va_mb[MAX_MAILBOX_NUM]; /* mailbox */
uint32_t mva_mb[MAX_MAILBOX_NUM];
uint32_t sz_mb[MAX_MAILBOX_NUM];
compat_uptr_t va_log[MAX_LOG_BUF_NUM]; /* log buffer */
uint32_t mva_log[MAX_LOG_BUF_NUM];
uint32_t sz_log[MAX_LOG_BUF_NUM];
int32_t fd_log[MAX_LOG_BUF_NUM];
};
#endif
/*---------------------------------------------------------------------------*/
/* CCU Power */
/*---------------------------------------------------------------------------*/
struct ccu_power_s {
uint32_t bON;
uint32_t freq;
uint32_t power;
struct ccu_working_buffer_s workBuf;
};
#ifdef CONFIG_COMPAT
struct compat_ccu_power_s {
uint32_t bON;
uint32_t freq;
uint32_t power;
struct compat_ccu_working_buffer_s workBuf;
};
#endif
/*---------------------------------------------------------------------------*/
/* CCU Run */
/*---------------------------------------------------------------------------*/
struct ccu_run_s {
uint32_t log_level;
uint32_t log_taglevel;
uint32_t CtrlBufMva;
uint32_t CpuRefBufMva;
uint32_t CpuRefBufSz;
uint32_t bkdata_ddr_buf_mva;
uint32_t AEShareBufMva;
uint32_t LTMShareBufMva;
uint32_t AFShareBufMva;
};
/*---------------------------------------------------------------------------*/
/* CCU command */
/*---------------------------------------------------------------------------*/
enum ccu_eng_status_e {
CCU_ENG_STATUS_SUCCESS,
CCU_ENG_STATUS_BUSY,
CCU_ENG_STATUS_TIMEOUT,
CCU_ENG_STATUS_INVALID,
CCU_ENG_STATUS_FLUSH,
CCU_ENG_STATUS_FAILURE,
CCU_ENG_STATUS_ERESTARTSYS,
};
/*---------------------------------------------------------------------------*/
/* CCU Command */
/*---------------------------------------------------------------------------*/
struct ccu_cmd_s {
struct ccu_msg task;
enum ccu_eng_status_e status;
};
#define CCU_IMPORT_BUF_NUM 200
#define CCU_IMPORT_BUF_UNDEF 0xFFFFFFFF
struct import_mem_s {
uint32_t memID[CCU_IMPORT_BUF_NUM];
};
/*---------------------------------------------------------------------------*/
/* CCU Read/Write Reg */
/*---------------------------------------------------------------------------*/
struct ccu_reg_s {
uint32_t reg_no;
uint32_t reg_val;
};
/*---------------------------------------------------------------------------*/
/* CAM FREQ */
/*---------------------------------------------------------------------------*/
#define CCU_REQ_CAM_FREQ_HIGH 2
#define CCU_REQ_CAM_FREQ_MID 1
#define CCU_REQ_CAM_FREQ_NONE 0
/*---------------------------------------------------------------------------*/
/* CCU LOAD BIN */
/*---------------------------------------------------------------------------*/
enum CCU_BIN_TYPE {
CCU_DP_BIN,
CCU_DDR_BIN,
CCU_DRIVER_BIN
};
#define CCU_BIN_NAME_MAX_LENGTH 50
struct ccu_bin_info_s {
enum CCU_BIN_TYPE type;
char name[CCU_BIN_NAME_MAX_LENGTH];
};
/*---------------------------------------------------------------------------*/
/* IOCTL Command */
/*---------------------------------------------------------------------------*/
#define CCU_MAGICNO 'c'
#define CCU_IOCTL_SET_POWER _IOW(CCU_MAGICNO, 0, int)
#define CCU_IOCTL_ENQUE_COMMAND _IOW(CCU_MAGICNO, 1, int)
#define CCU_IOCTL_DEQUE_COMMAND _IOWR(CCU_MAGICNO, 2, int)
#define CCU_IOCTL_FLUSH_COMMAND _IOW(CCU_MAGICNO, 3, int)
#define CCU_IOCTL_WAIT_AF_IRQ _IOW(CCU_MAGICNO, 8, int)
#define CCU_IOCTL_WAIT_IRQ _IOW(CCU_MAGICNO, 9, int)
#define CCU_IOCTL_SEND_CMD _IOWR(CCU_MAGICNO, 10, int)
#define CCU_IOCTL_SET_RUN_INPUT _IOW(CCU_MAGICNO, 11, int)
#define CCU_CLEAR_IRQ _IOW(CCU_MAGICNO, 12, int)
#define CCU_REGISTER_IRQ_USER_KEY _IOR(CCU_MAGICNO, 13, int)
#define CCU_READ_REGISTER _IOWR(CCU_MAGICNO, 14, int)
#define CCU_WRITE_REGISTER _IOWR(CCU_MAGICNO, 15, int)
#define CCU_IOCTL_SET_WORK_BUF _IOW(CCU_MAGICNO, 18, int)
#define CCU_IOCTL_FLUSH_LOG _IOW(CCU_MAGICNO, 19, int)
#define CCU_IOCTL_GET_I2C_DMA_BUF_ADDR _IOR(CCU_MAGICNO, 20, int)
#define CCU_IOCTL_SET_I2C_MODE _IOW(CCU_MAGICNO, 21, int)
#define CCU_IOCTL_GET_CURRENT_FPS _IOR(CCU_MAGICNO, 23, int)
#define CCU_IOCTL_GET_SENSOR_I2C_SLAVE_ADDR _IOR(CCU_MAGICNO, 24, int)
#define CCU_IOCTL_GET_SENSOR_NAME _IOR(CCU_MAGICNO, 25, int)
#define CCU_IOCTL_GET_PLATFORM_INFO _IOR(CCU_MAGICNO, 26, int)
#define CCU_IOCTL_IMPORT_MEM _IOW(CCU_MAGICNO, 27, int)
#define CCU_IOCTL_UPDATE_QOS_REQUEST _IOW(CCU_MAGICNO, 28, int)
#define CCU_IOCTL_UPDATE_CAM_FREQ_REQUEST _IOW(CCU_MAGICNO, 29, int)
#define CCU_IOCTL_LOAD_CCU_BIN _IOW(CCU_MAGICNO, 30, int)
#define CCU_IOCTL_IPC_INIT _IOW(CCU_MAGICNO, 31, int)
#define CCU_IOCTL_IPC_SEND_CMD _IOW(CCU_MAGICNO, 32, int)
#define CCU_IOCTL_ALLOC_MEM _IOW(CCU_MAGICNO, 33, int)
#define CCU_IOCTL_DEALLOC_MEM _IOW(CCU_MAGICNO, 34, int)
#define CCU_IOCTL_GET_IOVA _IOWR(CCU_MAGICNO, 35, int)
#define CCU_READ_STRUCT_SIZE _IOWR(CCU_MAGICNO, 36, int)
#define CCU_IOCTL_PRINT_REG _IOR(CCU_MAGICNO, 37, int)
#define CCU_IOCTL_PRINT_SRAM_LOG _IOR(CCU_MAGICNO, 38, int)
#define CCU_READ_DATA _IOWR(CCU_MAGICNO, 39, int)
#endif
+561
View File
@@ -0,0 +1,561 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2016 MediaTek Inc.
*/
#include <linux/types.h>
#include <linux/device.h>
#include <linux/cdev.h>
#include <linux/platform_device.h>
#include <linux/dma-mapping.h>
#include <linux/delay.h>
#include <linux/uaccess.h>
#include <linux/sched.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/io.h>
#include <linux/i2c.h>
#include "i2c-mtk.h"
#include <m4u.h>
#include "kd_camera_feature.h"/*for IMGSENSOR_SENSOR_IDX*/
#include "ccu_cmn.h"
#include "ccu_i2c.h"
#include "ccu_i2c_hw.h"
#include "ccu_mva.h"
#include "ccu_imgsensor.h"
/*******************************************************************************
*
******************************************************************************/
/*I2C Channel offset*/
#define I2C_BASE_OFS_CH1 (0x200)
#define MAX_I2C_CMD_LEN 255
#define CCU_I2C_APDMA_TXLEN 128
#define CCU_I2C_2_HW_DRVNAME "ccu_i2c_2_hwtrg"
#define CCU_I2C_4_HW_DRVNAME "ccu_i2c_4_hwtrg"
#define CCU_I2C_6_HW_DRVNAME "ccu_i2c_6_hwtrg"
#define CCU_I2C_7_HW_DRVNAME "ccu_i2c_7_hwtrg"
static DEFINE_MUTEX(ccu_i2c_mutex);
/*i2c driver hook*/
static int ccu_i2c_probe_2(struct i2c_client *client,
const struct i2c_device_id *id);
static int ccu_i2c_probe_4(struct i2c_client *client,
const struct i2c_device_id *id);
static int ccu_i2c_probe_6(struct i2c_client *client,
const struct i2c_device_id *id);
static int ccu_i2c_probe_7(struct i2c_client *client,
const struct i2c_device_id *id);
static int ccu_i2c_remove(struct i2c_client *client);
/*ccu i2c operation*/
static struct i2c_client *get_ccu_i2c_client(uint32_t i2c_id);
static void ccu_i2c_dump_info(struct mt_i2c *i2c);
static int ccu_i2c_controller_en(uint32_t i2c_id, int enable);
static int i2c_query_dma_buffer_addr(struct ccu_device_s
*g_ccu_device, uint32_t sensor_idx,
uint32_t *mva, uint32_t *va_h, uint32_t *va_l, uint32_t *i2c_id);
static int ccu_i2c_controller_uninit(uint32_t i2c_id);
/*i2c reg operation*/
static inline u32 i2c_readl_dma(struct mt_i2c *i2c, u8 offset);
static inline void i2c_writel_dma(u32 value, struct mt_i2c *i2c,
u8 offset);
static inline u16 i2c_readw(struct mt_i2c *i2c, u8 offset);
static inline void i2c_writew(u16 value, struct mt_i2c *i2c,
u16 offset);
static struct i2c_client *g_ccuI2cClient2;
static struct i2c_client *g_ccuI2cClient4;
static struct i2c_client *g_ccuI2cClient6;
static struct i2c_client *g_ccuI2cClient7;
static const struct i2c_device_id ccu_i2c_2_ids[]
= { {CCU_I2C_2_HW_DRVNAME, 0}, {} };
static const struct i2c_device_id ccu_i2c_4_ids[]
= { {CCU_I2C_4_HW_DRVNAME, 0}, {} };
static const struct i2c_device_id ccu_i2c_6_ids[]
= { {CCU_I2C_6_HW_DRVNAME, 0}, {} };
static const struct i2c_device_id ccu_i2c_7_ids[]
= { {CCU_I2C_7_HW_DRVNAME, 0}, {} };
static bool ccu_i2c_initialized[I2C_MAX_CHANNEL] = {0};
#ifdef CONFIG_OF
static const struct of_device_id ccu_i2c_2_driver_of_ids[] = {
{.compatible = "mediatek,ccu_sensor_i2c_2_hw",},
{}
};
static const struct of_device_id ccu_i2c_4_driver_of_ids[] = {
{.compatible = "mediatek,ccu_sensor_i2c_4_hw",},
{}
};
static const struct of_device_id ccu_i2c_6_driver_of_ids[] = {
{.compatible = "mediatek,ccu_sensor_i2c_6_hw",},
{}
};
static const struct of_device_id ccu_i2c_7_driver_of_ids[] = {
{.compatible = "mediatek,ccu_sensor_i2c_7_hw",},
{}
};
#endif
struct i2c_driver ccu_i2c_2_driver = {
.probe = ccu_i2c_probe_2,
.remove = ccu_i2c_remove,
.driver = {
.name = CCU_I2C_2_HW_DRVNAME,
.owner = THIS_MODULE,
#ifdef CONFIG_OF
.of_match_table = ccu_i2c_2_driver_of_ids,
#endif
},
.id_table = ccu_i2c_2_ids,
};
struct i2c_driver ccu_i2c_4_driver = {
.probe = ccu_i2c_probe_4,
.remove = ccu_i2c_remove,
.driver = {
.name = CCU_I2C_4_HW_DRVNAME,
.owner = THIS_MODULE,
#ifdef CONFIG_OF
.of_match_table = ccu_i2c_4_driver_of_ids,
#endif
},
.id_table = ccu_i2c_4_ids,
};
struct i2c_driver ccu_i2c_6_driver = {
.probe = ccu_i2c_probe_6,
.remove = ccu_i2c_remove,
.driver = {
.name = CCU_I2C_6_HW_DRVNAME,
.owner = THIS_MODULE,
#ifdef CONFIG_OF
.of_match_table = ccu_i2c_6_driver_of_ids,
#endif
},
.id_table = ccu_i2c_6_ids,
};
struct i2c_driver ccu_i2c_7_driver = {
.probe = ccu_i2c_probe_7,
.remove = ccu_i2c_remove,
.driver = {
.name = CCU_I2C_7_HW_DRVNAME,
.owner = THIS_MODULE,
#ifdef CONFIG_OF
.of_match_table = ccu_i2c_7_driver_of_ids,
#endif
},
.id_table = ccu_i2c_7_ids,
};
/*---------------------------------------------------------------------------*/
/* CCU Driver: i2c driver funcs */
/*---------------------------------------------------------------------------*/
static int ccu_i2c_probe_2(struct i2c_client *client,
const struct i2c_device_id *id)
{
LOG_DBG_MUST(
"[ccu_i2c_probe] Attach I2C for HW trriger g_ccuI2cClient2 %p\n",
client);
/* get sensor i2c client */
g_ccuI2cClient2 = client;
LOG_DBG_MUST("[ccu_i2c_probe] Attached!!\n");
return 0;
}
static int ccu_i2c_probe_4(struct i2c_client *client,
const struct i2c_device_id *id)
{
LOG_DBG_MUST(
"[ccu_i2c_probe] Attach I2C for HW trriger g_ccuI2cClient4 %p\n",
client);
/* get sensor i2c client */
g_ccuI2cClient4 = client;
LOG_DBG_MUST("[ccu_i2c_probe] Attached!!\n");
return 0;
}
static int ccu_i2c_probe_6(struct i2c_client *client,
const struct i2c_device_id *id)
{
LOG_DBG_MUST(
"[ccu_i2c_probe] Attach I2C for HW trriger g_ccuI2cClient6 %p\n",
client);
/* get sensor i2c client */
g_ccuI2cClient6 = client;
LOG_DBG_MUST("[ccu_i2c_probe] Attached!!\n");
return 0;
}
static int ccu_i2c_probe_7(struct i2c_client *client,
const struct i2c_device_id *id)
{
LOG_DBG_MUST(
"[ccu_i2c_probe] Attach I2C for HW trriger g_ccuI2cClient7 %p\n",
client);
/* get sensor i2c client */
g_ccuI2cClient7 = client;
LOG_DBG_MUST("[ccu_i2c_probe] Attached!!\n");
return 0;
}
static int ccu_i2c_remove(struct i2c_client *client)
{
return 0;
}
/*---------------------------------------------------------------------------*/
/* CCU i2c public funcs */
/*---------------------------------------------------------------------------*/
int ccu_i2c_register_driver(void)
{
int i2c_ret = 0;
mutex_lock(&ccu_i2c_mutex);
LOG_DBG_MUST("i2c_add_driver(&ccu_i2c_2_driver)++\n");
i2c_ret = i2c_add_driver(&ccu_i2c_2_driver);
LOG_DBG_MUST("i2c_add_driver(&ccu_i2c_2_driver), ret: %d--\n",
i2c_ret);
LOG_DBG_MUST("i2c_add_driver(&ccu_i2c_4_driver)++\n");
i2c_ret = i2c_add_driver(&ccu_i2c_4_driver);
LOG_DBG_MUST("i2c_add_driver(&ccu_i2c_4_driver), ret: %d--\n",
i2c_ret);
LOG_DBG_MUST("i2c_add_driver(&ccu_i2c_6_driver)++\n");
i2c_ret = i2c_add_driver(&ccu_i2c_6_driver);
LOG_DBG_MUST("i2c_add_driver(&ccu_i2c_6_driver), ret: %d--\n",
i2c_ret);
LOG_DBG_MUST("i2c_add_driver(&ccu_i2c_7_driver)++\n");
i2c_ret = i2c_add_driver(&ccu_i2c_7_driver);
LOG_DBG_MUST("i2c_add_driver(&ccu_i2c_7_driver), ret: %d--\n",
i2c_ret);
mutex_unlock(&ccu_i2c_mutex);
return 0;
}
int ccu_i2c_delete_driver(void)
{
mutex_lock(&ccu_i2c_mutex);
i2c_del_driver(&ccu_i2c_2_driver);
i2c_del_driver(&ccu_i2c_4_driver);
i2c_del_driver(&ccu_i2c_6_driver);
i2c_del_driver(&ccu_i2c_7_driver);
mutex_unlock(&ccu_i2c_mutex);
return 0;
}
int ccu_i2c_controller_init(uint32_t i2c_id)
{
mutex_lock(&ccu_i2c_mutex);
if (i2c_id >= I2C_MAX_CHANNEL) {
LOG_ERR("i2c_id %d is invalid\n", i2c_id);
mutex_unlock(&ccu_i2c_mutex);
return -EINVAL;
}
if (ccu_i2c_initialized[i2c_id] == MTRUE) {
/*if not first time init, release mutex first to avoid deadlock*/
LOG_DBG_MUST("reinit, temporily release mutex.\n");
}
if (ccu_i2c_controller_en(i2c_id, 1) == -1) {
LOG_DBG("ccu_i2c_controller_en 1 fail\n");
mutex_unlock(&ccu_i2c_mutex);
return -1;
}
LOG_DBG_MUST("%s done.\n", __func__);
mutex_unlock(&ccu_i2c_mutex);
return 0;
}
int ccu_i2c_controller_uninit_all(void)
{
int i;
mutex_lock(&ccu_i2c_mutex);
for (i = 0 ; i < I2C_MAX_CHANNEL ; i++) {
if (ccu_i2c_initialized[i])
ccu_i2c_controller_uninit(i);
}
LOG_INF_MUST("%s done.\n", __func__);
mutex_unlock(&ccu_i2c_mutex);
return 0;
}
int ccu_get_i2c_dma_buf_addr(struct ccu_device_s *g_ccu_device,
struct ccu_i2c_buf_mva_ioarg *ioarg)
{
int ret = 0;
mutex_lock(&ccu_i2c_mutex);
ret = i2c_query_dma_buffer_addr(g_ccu_device, ioarg->sensor_idx,
&ioarg->mva, &ioarg->va_h, &ioarg->va_l, &ioarg->i2c_id);
mutex_unlock(&ccu_i2c_mutex);
return ret;
}
int ccu_i2c_free_dma_buf_mva_all(struct ccu_device_s *g_ccu_device)
{
mutex_lock(&ccu_i2c_mutex);
ccu_deallocate_mva(g_ccu_device->i2c_dma_mva);
LOG_INF_MUST("%s done.\n", __func__);
mutex_unlock(&ccu_i2c_mutex);
return 0;
}
void ccu_i2c_dump_errr(void)
{
struct i2c_client *pClient = NULL;
struct mt_i2c *i2c;
int i;
for (i = 0 ; i < I2C_MAX_CHANNEL ; i++) {
LOG_INF_MUST(
"CCU Dump I2C controller[%d] reg =========\n", i);
pClient = get_ccu_i2c_client(i);
if (pClient != NULL) {
i2c = i2c_get_adapdata(pClient->adapter);
ccu_i2c_dump_info(i2c);
} else {
LOG_INF_MUST("I2C controller[%d] CCU client is null\n", i);
}
}
}
/*---------------------------------------------------------------------------*/
/* CCU i2c static funcs */
/*---------------------------------------------------------------------------*/
static int i2c_query_dma_buffer_addr(struct ccu_device_s *g_ccu_device,
uint32_t sensor_idx, uint32_t *mva, uint32_t *va_h,
uint32_t *va_l, uint32_t *i2c_id)
{
struct i2c_client *pClient = NULL;
struct mt_i2c *i2c;
int ret = 0;
*i2c_id = ccu_get_sensor_i2c_id(sensor_idx);
pClient = get_ccu_i2c_client(*i2c_id);
if (pClient == MNULL) {
LOG_ERR("ccu client is NULL");
return -EFAULT;
}
if (g_ccu_device->dev == MNULL) {
LOG_ERR("ccu device is NULL");
return -EFAULT;
}
i2c = i2c_get_adapdata(pClient->adapter);
if (g_ccu_device->i2c_dma_mva == 0) {
ret = ccu_allocate_mva(&g_ccu_device->i2c_dma_mva,
g_ccu_device->i2c_dma_vaddr,
CCU_I2C_DMA_BUF_SIZE);
if (ret != 0) {
LOG_ERR("ccu alloc mva fail");
return -EFAULT;
}
}
/*i2c_get_dma_buffer_addr_imp(pClient->adapter ,va);*/
*mva = g_ccu_device->i2c_dma_mva;
*va_l = g_ccu_device->i2c_dma_paddr;
*va_h = ((g_ccu_device->i2c_dma_paddr) >> 32);
*i2c_id = i2c->id;
LOG_DBG_MUST("$$pa(%lld), mva(%x), i2c-id(%d)\n",
g_ccu_device->i2c_dma_paddr,
g_ccu_device->i2c_dma_mva, (uint32_t)i2c->id);
return 0;
}
static int ccu_i2c_controller_en(uint32_t i2c_id, int enable)
{
int ret = 0;
struct i2c_client *pClient = NULL;
struct mt_i2c *i2c;
LOG_INF_MUST("%s, id(%d):(%d)->(%d)\n",
__func__, i2c_id, ccu_i2c_initialized[i2c_id], enable);
pClient = get_ccu_i2c_client(i2c_id);
LOG_DBG("%s, pClient: %p\n", __func__, pClient);
if (pClient == NULL) {
LOG_ERR("i2c_client is null\n");
return -1;
}
if (enable) {
if (ccu_i2c_initialized[i2c_id] == MFALSE) {
ret = i2c_ccu_enable(pClient->adapter, I2C_BASE_OFS_CH1);
ccu_i2c_initialized[i2c_id] = MTRUE;
LOG_INF_MUST("i2c_ccu_enable done.\n");
/*dump controller status*/
i2c = i2c_get_adapdata(pClient->adapter);
i2c_writew(2, i2c, 0x240); /*MCU_INTR re-direct to CCU only*/
}
} else {
if (ccu_i2c_initialized[i2c_id] == MTRUE) {
ret = i2c_ccu_disable(pClient->adapter);
ccu_i2c_initialized[i2c_id] = MFALSE;
LOG_INF_MUST("i2c_ccu_disable done.\n");
}
}
return ret;
}
static int ccu_i2c_controller_uninit(uint32_t i2c_id)
{
if (ccu_i2c_controller_en(i2c_id, 0) == -1) {
LOG_DBG("ccu_i2c_controller_en 0 fail\n");
return -1;
}
LOG_DBG_MUST("%s done: id(%d)\n", __func__, i2c_id);
return 0;
}
static struct i2c_client *get_ccu_i2c_client(uint32_t i2c_id)
{
switch (i2c_id) {
case 2:
{
return g_ccuI2cClient2;
}
case 4:
{
return g_ccuI2cClient4;
}
case 6:
{
return g_ccuI2cClient6;
}
case 7:
{
return g_ccuI2cClient7;
}
default:
{
return MNULL;
}
}
}
static inline u32 i2c_readl_dma(struct mt_i2c *i2c, u8 offset)
{
return readl(i2c->pdmabase + offset);
}
static inline void i2c_writel_dma(u32 value, struct mt_i2c *i2c,
u8 offset)
{
writel(value, i2c->pdmabase + offset);
}
static inline u16 i2c_readw(struct mt_i2c *i2c, u8 offset)
{
return readw(i2c->base + offset);
}
static inline void i2c_writew(u16 value, struct mt_i2c *i2c,
u16 offset)
{
writew(value, i2c->base + offset);
}
static void ccu_i2c_dump_info(struct mt_i2c *i2c)
{
/* I2CFUC(); */
/* int val=0; */
pr_info("i2c_dump_info ++++++++++++++++++++++++++++++++++++++++++\n");
pr_info("I2C structure:\n"
I2CTAG "Clk=%d,Id=%d,Op=%x,Irq_stat=%x,Total_len=%x\n"
I2CTAG "Trans_len=%x,Trans_num=%x,Trans_auxlen=%x,speed=%d\n"
I2CTAG "Trans_stop=%u\n",
15600, i2c->id, i2c->op, i2c->irq_stat, i2c->total_len,
i2c->msg_len, 1, i2c->msg_aux_len, i2c->speed_hz,
i2c->trans_stop);
pr_info("base address 0x%p\n", i2c->base);
pr_info("I2C register:\n"
I2CTAG "SLAVE_ADDR=%x,INTR_MASK=%x,INTR_STAT=%x,CONTROL=%x,TRANSFER_LEN=%x\n"
I2CTAG "TRANSAC_LEN=%x,DELAY_LEN=%x,TIMING=%x,START=%x,FIFO_STAT=%x\n"
I2CTAG "IO_CONFIG=%x,HS=%x,DCM_EN=%x,DEBUGSTAT=%x,EXT_CONF=%x,TRANSFER_LEN_AUX=%x\n",
(i2c_readw(i2c, OFFSET_SLAVE_ADDR)),
(i2c_readw(i2c, OFFSET_INTR_MASK)),
(i2c_readw(i2c, OFFSET_INTR_STAT)),
(i2c_readw(i2c, OFFSET_CONTROL)),
(i2c_readw(i2c, OFFSET_TRANSFER_LEN)),
(i2c_readw(i2c, OFFSET_TRANSAC_LEN)),
(i2c_readw(i2c, OFFSET_DELAY_LEN)),
(i2c_readw(i2c, OFFSET_TIMING)),
(i2c_readw(i2c, OFFSET_START)),
(i2c_readw(i2c, OFFSET_FIFO_STAT)),
(i2c_readw(i2c, OFFSET_IO_CONFIG)),
(i2c_readw(i2c, OFFSET_HS)),
(i2c_readw(i2c, OFFSET_DCM_EN)),
(i2c_readw(i2c, OFFSET_DEBUGSTAT)),
(i2c_readw(i2c, OFFSET_EXT_CONF)), (i2c_readw(i2c,
OFFSET_TRANSFER_LEN_AUX)));
pr_info("DMA register(0x%p):\n"
I2CTAG "INT_FLAG=%x,INT_EN=%x,EN=%x,RST=%x,\n"
I2CTAG "STOP=%x,FLUSH=%x,CON=%x,TX_MEM_ADDR=%x, RX_MEM_ADDR=%x\n"
I2CTAG "TX_LEN=%x,RX_LEN=%x,INT_BUF_SIZE=%x,DEBUG_STATUS=%x\n"
I2CTAG "TX_MEM_ADDR2=%x, RX_MEM_ADDR2=%x\n",
i2c->pdmabase,
(i2c_readl_dma(i2c, OFFSET_INT_FLAG)),
(i2c_readl_dma(i2c, OFFSET_INT_EN)),
(i2c_readl_dma(i2c, OFFSET_EN)),
(i2c_readl_dma(i2c, OFFSET_RST)),
(i2c_readl_dma(i2c, OFFSET_STOP)),
(i2c_readl_dma(i2c, OFFSET_FLUSH)),
(i2c_readl_dma(i2c, OFFSET_CON)),
(i2c_readl_dma(i2c, OFFSET_TX_MEM_ADDR)),
(i2c_readl_dma(i2c, OFFSET_RX_MEM_ADDR)),
(i2c_readl_dma(i2c, OFFSET_TX_LEN)),
(i2c_readl_dma(i2c, OFFSET_RX_LEN)),
(i2c_readl_dma(i2c, OFFSET_INT_BUF_SIZE)),
(i2c_readl_dma(i2c, OFFSET_DEBUG_STA)),
(i2c_readl_dma(i2c, OFFSET_TX_MEM_ADDR2)),
(i2c_readl_dma(i2c, OFFSET_RX_MEM_ADDR2)));
pr_info("i2c_dump_info ------------------------------------------\n");
}
@@ -0,0 +1,27 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2016 MediaTek Inc.
*/
#ifndef __CCU_I2C_H__
#define __CCU_I2C_H__
struct ccu_i2c_buf_mva_ioarg {
uint32_t sensor_idx;
uint32_t mva;
uint32_t va_h;
uint32_t va_l;
uint32_t i2c_id;
};
/*i2c driver hook*/
int ccu_i2c_register_driver(void);
int ccu_i2c_delete_driver(void);
/*ccu i2c operation*/
int ccu_get_i2c_dma_buf_addr(struct ccu_device_s *g_ccu_device, struct ccu_i2c_buf_mva_ioarg *ioarg);
int ccu_i2c_controller_init(uint32_t i2c_id);
int ccu_i2c_controller_uninit_all(void);
int ccu_i2c_free_dma_buf_mva_all(struct ccu_device_s *g_ccu_device);
void ccu_i2c_dump_errr(void);
#endif
@@ -0,0 +1,20 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2016 MediaTek Inc.
*/
#include <linux/io.h>
#include "ccu_drv.h"
#include "ccu_cmn.h"
#include "ccu_n3d_a.h"
inline u32 n3d_a_readw(unsigned long n3d_a_base, u32 offset)
{
return readl((u32 *) (n3d_a_base + offset));
}
inline void n3d_a_writew(u32 value, unsigned long n3d_a_base, u32 offset)
{
writel(value, (u32 *) (n3d_a_base + offset));
}
@@ -0,0 +1,19 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2016 MediaTek Inc.
*/
#ifndef __CCU_N3D_A_H__
#define __CCU_N3D_A_H__
enum N3DA_REGS_OFFSET {
OFFSET_CTL = 0x100,
OFFSET_TRIG = 0x108,
OFFSET_INT = 0x10C,
};
extern u32 n3d_a_readw(unsigned long n3d_a_base, u32 offset);
extern void n3d_a_writew(u32 value, unsigned long n3d_a_base, u32 offset);
#endif