Commit ab29a247 authored by Bingbu Cao's avatar Bingbu Cao Committed by Hans Verkuil

media: intel/ipu6: add IPU6 buttress interface driver

The IPU6 buttress is the interface between IPU device (input system and
processing system) with rest of the SoC. It contains overall IPU hardware
control registers, these control registers are used as the interfaces with
the Intel Converged Security Engine and Punit to do firmware
authentication and power management.
Signed-off-by: default avatarBingbu Cao <bingbu.cao@intel.com>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
parent cb3117b0
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (C) 2013--2024 Intel Corporation */
#ifndef IPU6_BUTTRESS_H
#define IPU6_BUTTRESS_H
#include <linux/completion.h>
#include <linux/irqreturn.h>
#include <linux/list.h>
#include <linux/mutex.h>
struct device;
struct firmware;
struct ipu6_device;
struct ipu6_bus_device;
#define BUTTRESS_PS_FREQ_STEP 25U
#define BUTTRESS_MIN_FORCE_PS_FREQ (BUTTRESS_PS_FREQ_STEP * 8)
#define BUTTRESS_MAX_FORCE_PS_FREQ (BUTTRESS_PS_FREQ_STEP * 32)
#define BUTTRESS_IS_FREQ_STEP 25U
#define BUTTRESS_MIN_FORCE_IS_FREQ (BUTTRESS_IS_FREQ_STEP * 8)
#define BUTTRESS_MAX_FORCE_IS_FREQ (BUTTRESS_IS_FREQ_STEP * 22)
struct ipu6_buttress_ctrl {
u32 freq_ctl, pwr_sts_shift, pwr_sts_mask, pwr_sts_on, pwr_sts_off;
unsigned int ratio;
unsigned int qos_floor;
bool started;
};
struct ipu6_buttress_ipc {
struct completion send_complete;
struct completion recv_complete;
u32 nack;
u32 nack_mask;
u32 recv_data;
u32 csr_out;
u32 csr_in;
u32 db0_in;
u32 db0_out;
u32 data0_out;
u32 data0_in;
};
struct ipu6_buttress {
struct mutex power_mutex, auth_mutex, cons_mutex, ipc_mutex;
struct ipu6_buttress_ipc cse;
struct ipu6_buttress_ipc ish;
struct list_head constraints;
u32 wdt_cached_value;
bool force_suspend;
u32 ref_clk;
};
enum ipu6_buttress_ipc_domain {
IPU6_BUTTRESS_IPC_CSE,
IPU6_BUTTRESS_IPC_ISH,
};
struct ipu6_ipc_buttress_bulk_msg {
u32 cmd;
u32 expected_resp;
bool require_resp;
u8 cmd_size;
};
int ipu6_buttress_ipc_reset(struct ipu6_device *isp,
struct ipu6_buttress_ipc *ipc);
int ipu6_buttress_map_fw_image(struct ipu6_bus_device *sys,
const struct firmware *fw,
struct sg_table *sgt);
void ipu6_buttress_unmap_fw_image(struct ipu6_bus_device *sys,
struct sg_table *sgt);
int ipu6_buttress_power(struct device *dev, struct ipu6_buttress_ctrl *ctrl,
bool on);
bool ipu6_buttress_get_secure_mode(struct ipu6_device *isp);
int ipu6_buttress_authenticate(struct ipu6_device *isp);
int ipu6_buttress_reset_authentication(struct ipu6_device *isp);
bool ipu6_buttress_auth_done(struct ipu6_device *isp);
int ipu6_buttress_start_tsc_sync(struct ipu6_device *isp);
void ipu6_buttress_tsc_read(struct ipu6_device *isp, u64 *val);
u64 ipu6_buttress_tsc_ticks_to_ns(u64 ticks, const struct ipu6_device *isp);
irqreturn_t ipu6_buttress_isr(int irq, void *isp_ptr);
irqreturn_t ipu6_buttress_isr_threaded(int irq, void *isp_ptr);
int ipu6_buttress_init(struct ipu6_device *isp);
void ipu6_buttress_exit(struct ipu6_device *isp);
void ipu6_buttress_csi_port_config(struct ipu6_device *isp,
u32 legacy, u32 combo);
void ipu6_buttress_restore(struct ipu6_device *isp);
#endif /* IPU6_BUTTRESS_H */
/* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (C) 2023--2024 Intel Corporation */
#ifndef IPU6_PLATFORM_BUTTRESS_REGS_H
#define IPU6_PLATFORM_BUTTRESS_REGS_H
#include <linux/bits.h>
/* IS_WORKPOINT_REQ */
#define IPU6_BUTTRESS_REG_IS_FREQ_CTL 0x34
/* PS_WORKPOINT_REQ */
#define IPU6_BUTTRESS_REG_PS_FREQ_CTL 0x38
/* should be tuned for real silicon */
#define IPU6_IS_FREQ_CTL_DEFAULT_RATIO 0x08
#define IPU6SE_IS_FREQ_CTL_DEFAULT_RATIO 0x0a
#define IPU6_PS_FREQ_CTL_DEFAULT_RATIO 0x0d
#define IPU6_IS_FREQ_CTL_DEFAULT_QOS_FLOOR_RATIO 0x10
#define IPU6_PS_FREQ_CTL_DEFAULT_QOS_FLOOR_RATIO 0x0708
#define IPU6_BUTTRESS_PWR_STATE_IS_PWR_SHIFT 3
#define IPU6_BUTTRESS_PWR_STATE_IS_PWR_MASK GENMASK(4, 3)
#define IPU6_BUTTRESS_PWR_STATE_PS_PWR_SHIFT 6
#define IPU6_BUTTRESS_PWR_STATE_PS_PWR_MASK GENMASK(7, 6)
#define IPU6_BUTTRESS_PWR_STATE_DN_DONE 0x0
#define IPU6_BUTTRESS_PWR_STATE_UP_PROCESS 0x1
#define IPU6_BUTTRESS_PWR_STATE_DN_PROCESS 0x2
#define IPU6_BUTTRESS_PWR_STATE_UP_DONE 0x3
#define IPU6_BUTTRESS_REG_FPGA_SUPPORT_0 0x270
#define IPU6_BUTTRESS_REG_FPGA_SUPPORT_1 0x274
#define IPU6_BUTTRESS_REG_FPGA_SUPPORT_2 0x278
#define IPU6_BUTTRESS_REG_FPGA_SUPPORT_3 0x27c
#define IPU6_BUTTRESS_REG_FPGA_SUPPORT_4 0x280
#define IPU6_BUTTRESS_REG_FPGA_SUPPORT_5 0x284
#define IPU6_BUTTRESS_REG_FPGA_SUPPORT_6 0x288
#define IPU6_BUTTRESS_REG_FPGA_SUPPORT_7 0x28c
#define BUTTRESS_REG_WDT 0x8
#define BUTTRESS_REG_BTRS_CTRL 0xc
#define BUTTRESS_REG_BTRS_CTRL_STALL_MODE_VC0 BIT(0)
#define BUTTRESS_REG_BTRS_CTRL_STALL_MODE_VC1 BIT(1)
#define BUTTRESS_REG_BTRS_CTRL_REF_CLK_IND GENMASK(9, 8)
#define BUTTRESS_REG_FW_RESET_CTL 0x30
#define BUTTRESS_FW_RESET_CTL_START BIT(0)
#define BUTTRESS_FW_RESET_CTL_DONE BIT(1)
#define BUTTRESS_REG_IS_FREQ_CTL 0x34
#define BUTTRESS_REG_PS_FREQ_CTL 0x38
#define BUTTRESS_FREQ_CTL_START BIT(31)
#define BUTTRESS_FREQ_CTL_ICCMAX_LEVEL GENMASK(19, 16)
#define BUTTRESS_FREQ_CTL_QOS_FLOOR_MASK GENMASK(15, 8)
#define BUTTRESS_FREQ_CTL_RATIO_MASK GENMASK(7, 0)
#define BUTTRESS_REG_PWR_STATE 0x5c
#define BUTTRESS_PWR_STATE_RESET 0x0
#define BUTTRESS_PWR_STATE_PWR_ON_DONE 0x1
#define BUTTRESS_PWR_STATE_PWR_RDY 0x3
#define BUTTRESS_PWR_STATE_PWR_IDLE 0x4
#define BUTTRESS_PWR_STATE_HH_STATUS_MASK GENMASK(12, 11)
enum {
BUTTRESS_PWR_STATE_HH_STATE_IDLE,
BUTTRESS_PWR_STATE_HH_STATE_IN_PRGS,
BUTTRESS_PWR_STATE_HH_STATE_DONE,
BUTTRESS_PWR_STATE_HH_STATE_ERR,
};
#define BUTTRESS_PWR_STATE_IS_PWR_FSM_MASK GENMASK(23, 19)
#define BUTTRESS_PWR_STATE_IS_PWR_FSM_IDLE 0x0
#define BUTTRESS_PWR_STATE_IS_PWR_FSM_WAIT_4_PLL_CMP 0x1
#define BUTTRESS_PWR_STATE_IS_PWR_FSM_WAIT_4_CLKACK 0x2
#define BUTTRESS_PWR_STATE_IS_PWR_FSM_WAIT_4_PG_ACK 0x3
#define BUTTRESS_PWR_STATE_IS_PWR_FSM_RST_ASSRT_CYCLES 0x4
#define BUTTRESS_PWR_STATE_IS_PWR_FSM_STOP_CLK_CYCLES1 0x5
#define BUTTRESS_PWR_STATE_IS_PWR_FSM_STOP_CLK_CYCLES2 0x6
#define BUTTRESS_PWR_STATE_IS_PWR_FSM_RST_DEASSRT_CYCLES 0x7
#define BUTTRESS_PWR_STATE_IS_PWR_FSM_WAIT_4_FUSE_WR_CMP 0x8
#define BUTTRESS_PWR_STATE_IS_PWR_FSM_BRK_POINT 0x9
#define BUTTRESS_PWR_STATE_IS_PWR_FSM_IS_RDY 0xa
#define BUTTRESS_PWR_STATE_IS_PWR_FSM_HALT_HALTED 0xb
#define BUTTRESS_PWR_STATE_IS_PWR_FSM_RST_DURATION_CNT3 0xc
#define BUTTRESS_PWR_STATE_IS_PWR_FSM_WAIT_4_CLKACK_PD 0xd
#define BUTTRESS_PWR_STATE_IS_PWR_FSM_PD_BRK_POINT 0xe
#define BUTTRESS_PWR_STATE_IS_PWR_FSM_WAIT_4_PD_PG_ACK0 0xf
#define BUTTRESS_PWR_STATE_PS_PWR_FSM_MASK GENMASK(28, 24)
#define BUTTRESS_PWR_STATE_PS_PWR_FSM_IDLE 0x0
#define BUTTRESS_PWR_STATE_PS_PWR_FSM_WAIT_PU_PLL_IP_RDY 0x1
#define BUTTRESS_PWR_STATE_PS_PWR_FSM_WAIT_RO_PRE_CNT_EXH 0x2
#define BUTTRESS_PWR_STATE_PS_PWR_FSM_WAIT_PU_VGI_PWRGOOD 0x3
#define BUTTRESS_PWR_STATE_PS_PWR_FSM_WAIT_RO_POST_CNT_EXH 0x4
#define BUTTRESS_PWR_STATE_PS_PWR_FSM_WR_PLL_RATIO 0x5
#define BUTTRESS_PWR_STATE_PS_PWR_FSM_WAIT_PU_PLL_CMP 0x6
#define BUTTRESS_PWR_STATE_PS_PWR_FSM_WAIT_PU_CLKACK 0x7
#define BUTTRESS_PWR_STATE_PS_PWR_FSM_RST_ASSRT_CYCLES 0x8
#define BUTTRESS_PWR_STATE_PS_PWR_FSM_STOP_CLK_CYCLES1 0x9
#define BUTTRESS_PWR_STATE_PS_PWR_FSM_STOP_CLK_CYCLES2 0xa
#define BUTTRESS_PWR_STATE_PS_PWR_FSM_RST_DEASSRT_CYCLES 0xb
#define BUTTRESS_PWR_STATE_PS_PWR_FSM_PU_BRK_PNT 0xc
#define BUTTRESS_PWR_STATE_PS_PWR_FSM_WAIT_FUSE_ACCPT 0xd
#define BUTTRESS_PWR_STATE_PS_PWR_FSM_PS_PWR_UP 0xf
#define BUTTRESS_PWR_STATE_PS_PWR_FSM_WAIT_4_HALTED 0x10
#define BUTTRESS_PWR_STATE_PS_PWR_FSM_RESET_CNT3 0x11
#define BUTTRESS_PWR_STATE_PS_PWR_FSM_WAIT_PD_CLKACK 0x12
#define BUTTRESS_PWR_STATE_PS_PWR_FSM_WAIT_PD_OFF_IND 0x13
#define BUTTRESS_PWR_STATE_PS_PWR_FSM_WAIT_DVFS_PH4 0x14
#define BUTTRESS_PWR_STATE_PS_PWR_FSM_WAIT_DVFS_PLL_CMP 0x15
#define BUTTRESS_PWR_STATE_PS_PWR_FSM_WAIT_DVFS_CLKACK 0x16
#define BUTTRESS_REG_SECURITY_CTL 0x300
#define BUTTRESS_REG_SKU 0x314
#define BUTTRESS_REG_SECURITY_TOUCH 0x318
#define BUTTRESS_REG_CAMERA_MASK 0x84
#define BUTTRESS_SECURITY_CTL_FW_SECURE_MODE BIT(16)
#define BUTTRESS_SECURITY_CTL_FW_SETUP_MASK GENMASK(4, 0)
#define BUTTRESS_SECURITY_CTL_FW_SETUP_DONE BIT(0)
#define BUTTRESS_SECURITY_CTL_AUTH_DONE BIT(1)
#define BUTTRESS_SECURITY_CTL_AUTH_FAILED BIT(3)
#define BUTTRESS_REG_FW_SOURCE_BASE_LO 0x78
#define BUTTRESS_REG_FW_SOURCE_BASE_HI 0x7C
#define BUTTRESS_REG_FW_SOURCE_SIZE 0x80
#define BUTTRESS_REG_ISR_STATUS 0x90
#define BUTTRESS_REG_ISR_ENABLED_STATUS 0x94
#define BUTTRESS_REG_ISR_ENABLE 0x98
#define BUTTRESS_REG_ISR_CLEAR 0x9C
#define BUTTRESS_ISR_IS_IRQ BIT(0)
#define BUTTRESS_ISR_PS_IRQ BIT(1)
#define BUTTRESS_ISR_IPC_EXEC_DONE_BY_CSE BIT(2)
#define BUTTRESS_ISR_IPC_EXEC_DONE_BY_ISH BIT(3)
#define BUTTRESS_ISR_IPC_FROM_CSE_IS_WAITING BIT(4)
#define BUTTRESS_ISR_IPC_FROM_ISH_IS_WAITING BIT(5)
#define BUTTRESS_ISR_CSE_CSR_SET BIT(6)
#define BUTTRESS_ISR_ISH_CSR_SET BIT(7)
#define BUTTRESS_ISR_SPURIOUS_CMP BIT(8)
#define BUTTRESS_ISR_WATCHDOG_EXPIRED BIT(9)
#define BUTTRESS_ISR_PUNIT_2_IUNIT_IRQ BIT(10)
#define BUTTRESS_ISR_SAI_VIOLATION BIT(11)
#define BUTTRESS_ISR_HW_ASSERTION BIT(12)
#define BUTTRESS_ISR_IS_CORRECTABLE_MEM_ERR BIT(13)
#define BUTTRESS_ISR_IS_FATAL_MEM_ERR BIT(14)
#define BUTTRESS_ISR_IS_NON_FATAL_MEM_ERR BIT(15)
#define BUTTRESS_ISR_PS_CORRECTABLE_MEM_ERR BIT(16)
#define BUTTRESS_ISR_PS_FATAL_MEM_ERR BIT(17)
#define BUTTRESS_ISR_PS_NON_FATAL_MEM_ERR BIT(18)
#define BUTTRESS_ISR_PS_FAST_THROTTLE BIT(19)
#define BUTTRESS_ISR_UFI_ERROR BIT(20)
#define BUTTRESS_REG_IU2CSEDB0 0x100
#define BUTTRESS_IU2CSEDB0_BUSY BIT(31)
#define BUTTRESS_IU2CSEDB0_IPC_CLIENT_ID_VAL 2
#define BUTTRESS_REG_IU2CSEDATA0 0x104
#define BUTTRESS_IU2CSEDATA0_IPC_BOOT_LOAD 1
#define BUTTRESS_IU2CSEDATA0_IPC_AUTH_RUN 2
#define BUTTRESS_IU2CSEDATA0_IPC_AUTH_REPLACE 3
#define BUTTRESS_IU2CSEDATA0_IPC_UPDATE_SECURE_TOUCH 16
#define BUTTRESS_CSE2IUDATA0_IPC_BOOT_LOAD_DONE BIT(0)
#define BUTTRESS_CSE2IUDATA0_IPC_AUTH_RUN_DONE BIT(1)
#define BUTTRESS_CSE2IUDATA0_IPC_AUTH_REPLACE_DONE BIT(2)
#define BUTTRESS_CSE2IUDATA0_IPC_UPDATE_SECURE_TOUCH_DONE BIT(4)
#define BUTTRESS_REG_IU2CSECSR 0x108
#define BUTTRESS_IU2CSECSR_IPC_PEER_COMP_ACTIONS_RST_PHASE1 BIT(0)
#define BUTTRESS_IU2CSECSR_IPC_PEER_COMP_ACTIONS_RST_PHASE2 BIT(1)
#define BUTTRESS_IU2CSECSR_IPC_PEER_QUERIED_IP_COMP_ACTIONS_RST_PHASE BIT(2)
#define BUTTRESS_IU2CSECSR_IPC_PEER_ASSERTED_REG_VALID_REQ BIT(3)
#define BUTTRESS_IU2CSECSR_IPC_PEER_ACKED_REG_VALID BIT(4)
#define BUTTRESS_IU2CSECSR_IPC_PEER_DEASSERTED_REG_VALID_REQ BIT(5)
#define BUTTRESS_REG_CSE2IUDB0 0x304
#define BUTTRESS_REG_CSE2IUCSR 0x30C
#define BUTTRESS_REG_CSE2IUDATA0 0x308
/* 0x20 == NACK, 0xf == unknown command */
#define BUTTRESS_CSE2IUDATA0_IPC_NACK 0xf20
#define BUTTRESS_CSE2IUDATA0_IPC_NACK_MASK GENMASK(15, 0)
#define BUTTRESS_REG_ISH2IUCSR 0x50
#define BUTTRESS_REG_ISH2IUDB0 0x54
#define BUTTRESS_REG_ISH2IUDATA0 0x58
#define BUTTRESS_REG_IU2ISHDB0 0x10C
#define BUTTRESS_REG_IU2ISHDATA0 0x110
#define BUTTRESS_REG_IU2ISHDATA1 0x114
#define BUTTRESS_REG_IU2ISHCSR 0x118
#define BUTTRESS_REG_FABRIC_CMD 0x88
#define BUTTRESS_FABRIC_CMD_START_TSC_SYNC BIT(0)
#define BUTTRESS_FABRIC_CMD_IS_DRAIN BIT(4)
#define BUTTRESS_REG_TSW_CTL 0x120
#define BUTTRESS_TSW_CTL_SOFT_RESET BIT(8)
#define BUTTRESS_REG_TSC_LO 0x164
#define BUTTRESS_REG_TSC_HI 0x168
#define BUTTRESS_IRQS (BUTTRESS_ISR_IPC_FROM_CSE_IS_WAITING | \
BUTTRESS_ISR_IPC_EXEC_DONE_BY_CSE | \
BUTTRESS_ISR_IS_IRQ | BUTTRESS_ISR_PS_IRQ)
#define BUTTRESS_EVENT (BUTTRESS_ISR_IPC_FROM_CSE_IS_WAITING | \
BUTTRESS_ISR_IPC_FROM_ISH_IS_WAITING | \
BUTTRESS_ISR_IPC_EXEC_DONE_BY_CSE | \
BUTTRESS_ISR_IPC_EXEC_DONE_BY_ISH | \
BUTTRESS_ISR_SAI_VIOLATION)
#endif /* IPU6_PLATFORM_BUTTRESS_REGS_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment