xref: /linux/drivers/media/pci/intel/ipu6/ipu6-buttress.h (revision 7f71507851fc7764b36a3221839607d3a45c2025)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright (C) 2013--2024 Intel Corporation */
3 
4 #ifndef IPU6_BUTTRESS_H
5 #define IPU6_BUTTRESS_H
6 
7 #include <linux/completion.h>
8 #include <linux/irqreturn.h>
9 #include <linux/list.h>
10 #include <linux/mutex.h>
11 
12 struct device;
13 struct firmware;
14 struct ipu6_device;
15 struct ipu6_bus_device;
16 
17 #define BUTTRESS_PS_FREQ_STEP		25U
18 #define BUTTRESS_MIN_FORCE_PS_FREQ	(BUTTRESS_PS_FREQ_STEP * 8)
19 #define BUTTRESS_MAX_FORCE_PS_FREQ	(BUTTRESS_PS_FREQ_STEP * 32)
20 
21 #define BUTTRESS_IS_FREQ_STEP		25U
22 #define BUTTRESS_MIN_FORCE_IS_FREQ	(BUTTRESS_IS_FREQ_STEP * 8)
23 #define BUTTRESS_MAX_FORCE_IS_FREQ	(BUTTRESS_IS_FREQ_STEP * 22)
24 
25 struct ipu6_buttress_ctrl {
26 	u32 freq_ctl, pwr_sts_shift, pwr_sts_mask, pwr_sts_on, pwr_sts_off;
27 	unsigned int ratio;
28 	unsigned int qos_floor;
29 	bool started;
30 };
31 
32 struct ipu6_buttress_ipc {
33 	struct completion send_complete;
34 	struct completion recv_complete;
35 	u32 nack;
36 	u32 nack_mask;
37 	u32 recv_data;
38 	u32 csr_out;
39 	u32 csr_in;
40 	u32 db0_in;
41 	u32 db0_out;
42 	u32 data0_out;
43 	u32 data0_in;
44 };
45 
46 struct ipu6_buttress {
47 	struct mutex power_mutex, auth_mutex, cons_mutex, ipc_mutex;
48 	struct ipu6_buttress_ipc cse;
49 	struct list_head constraints;
50 	u32 wdt_cached_value;
51 	bool force_suspend;
52 	u32 ref_clk;
53 };
54 
55 struct ipu6_ipc_buttress_bulk_msg {
56 	u32 cmd;
57 	u32 expected_resp;
58 	bool require_resp;
59 	u8 cmd_size;
60 };
61 
62 int ipu6_buttress_ipc_reset(struct ipu6_device *isp,
63 			    struct ipu6_buttress_ipc *ipc);
64 int ipu6_buttress_map_fw_image(struct ipu6_bus_device *sys,
65 			       const struct firmware *fw,
66 			       struct sg_table *sgt);
67 void ipu6_buttress_unmap_fw_image(struct ipu6_bus_device *sys,
68 				  struct sg_table *sgt);
69 int ipu6_buttress_power(struct device *dev, struct ipu6_buttress_ctrl *ctrl,
70 			bool on);
71 bool ipu6_buttress_get_secure_mode(struct ipu6_device *isp);
72 int ipu6_buttress_authenticate(struct ipu6_device *isp);
73 int ipu6_buttress_reset_authentication(struct ipu6_device *isp);
74 bool ipu6_buttress_auth_done(struct ipu6_device *isp);
75 int ipu6_buttress_start_tsc_sync(struct ipu6_device *isp);
76 void ipu6_buttress_tsc_read(struct ipu6_device *isp, u64 *val);
77 u64 ipu6_buttress_tsc_ticks_to_ns(u64 ticks, const struct ipu6_device *isp);
78 
79 irqreturn_t ipu6_buttress_isr(int irq, void *isp_ptr);
80 irqreturn_t ipu6_buttress_isr_threaded(int irq, void *isp_ptr);
81 int ipu6_buttress_init(struct ipu6_device *isp);
82 void ipu6_buttress_exit(struct ipu6_device *isp);
83 void ipu6_buttress_csi_port_config(struct ipu6_device *isp,
84 				   u32 legacy, u32 combo);
85 void ipu6_buttress_restore(struct ipu6_device *isp);
86 #endif /* IPU6_BUTTRESS_H */
87