blob: 178e734bbc6dc759676a862a1b95a1f3f462a683 [file] [log] [blame]
Vishalsingh Hajeri71fc3c52018-01-15 20:28:29 -08001/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
Lakshmi Narayana Kalavala85c40352017-05-15 16:19:13 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef _HFI_INTF_H_
14#define _HFI_INTF_H_
15
16#include <linux/types.h>
17
18/**
19 * struct hfi_mem
20 * @len: length of memory
21 * @kva: kernel virtual address
22 * @iova: IO virtual address
23 * @reserved: reserved field
24 */
25struct hfi_mem {
26 uint64_t len;
27 uint64_t kva;
28 uint32_t iova;
29 uint32_t reserved;
30};
31
32/**
33 * struct hfi_mem_info
34 * @qtbl: qtable hfi memory
35 * @cmd_q: command queue hfi memory for host to firmware communication
36 * @msg_q: message queue hfi memory for firmware to host communication
37 * @dbg_q: debug queue hfi memory for firmware debug information
38 * @sec_heap: secondary heap hfi memory for firmware
39 * @icp_base: icp base address
40 */
41struct hfi_mem_info {
42 struct hfi_mem qtbl;
43 struct hfi_mem cmd_q;
44 struct hfi_mem msg_q;
45 struct hfi_mem dbg_q;
46 struct hfi_mem sec_heap;
Lakshmi Narayana Kalavala2743a0d2017-05-30 10:41:37 -070047 struct hfi_mem shmem;
Lakshmi Narayana Kalavala85c40352017-05-15 16:19:13 -070048 void __iomem *icp_base;
49};
50
51/**
52 * hfi_write_cmd() - function for hfi write
53 * @cmd_ptr: pointer to command data for hfi write
54 *
55 * Returns success(zero)/failure(non zero)
56 */
57int hfi_write_cmd(void *cmd_ptr);
58
59/**
60 * hfi_read_message() - function for hfi read
61 * @pmsg: buffer to place read message for hfi queue
62 * @q_id: queue id
Karthik Anantha Ramad347282017-11-01 13:09:17 -070063 * @words_read: total number of words read from the queue
64 * returned as output to the caller
Lakshmi Narayana Kalavala85c40352017-05-15 16:19:13 -070065 *
Karthik Anantha Ramad347282017-11-01 13:09:17 -070066 * Returns success(zero)/failure(non zero)
Lakshmi Narayana Kalavala85c40352017-05-15 16:19:13 -070067 */
Karthik Anantha Ramad347282017-11-01 13:09:17 -070068int hfi_read_message(uint32_t *pmsg, uint8_t q_id, uint32_t *words_read);
Lakshmi Narayana Kalavala85c40352017-05-15 16:19:13 -070069
70/**
71 * hfi_init() - function initialize hfi after firmware download
72 * @event_driven_mode: event mode
73 * @hfi_mem: hfi memory info
74 * @icp_base: icp base address
75 * @debug: debug flag
76 *
77 * Returns success(zero)/failure(non zero)
78 */
79int cam_hfi_init(uint8_t event_driven_mode, struct hfi_mem_info *hfi_mem,
80 void *__iomem icp_base, bool debug);
81
82/**
83 * hfi_get_hw_caps() - hardware capabilities from firmware
84 * @query_caps: holds query information from hfi
85 *
86 * Returns success(zero)/failure(non zero)
87 */
88int hfi_get_hw_caps(void *query_caps);
89
90/**
91 * hfi_send_system_cmd() - send hfi system command to firmware
92 * @type: type of system command
93 * @data: command data
94 * @size: size of command data
95 */
96void hfi_send_system_cmd(uint32_t type, uint64_t data, uint32_t size);
97
98/**
99 * cam_hfi_enable_cpu() - enable A5 CPU
100 * @icp_base: icp base address
101 */
102void cam_hfi_enable_cpu(void __iomem *icp_base);
Suresh Vankadarad8905f42017-06-04 13:33:49 +0530103
104/**
105 * cam_hfi_disable_cpu() - disable A5 CPU
106 * @icp_base: icp base address
107 */
108void cam_hfi_disable_cpu(void __iomem *icp_base);
109
Lakshmi Narayana Kalavala85c40352017-05-15 16:19:13 -0700110/**
111 * cam_hfi_deinit() - cleanup HFI
112 */
Vishalsingh Hajeri71fc3c52018-01-15 20:28:29 -0800113void cam_hfi_deinit(void __iomem *icp_base);
Lakshmi Narayana Kalavaladac0b6c2017-09-13 15:33:42 -0700114/**
115 * hfi_set_debug_level() - set debug level
116 * @lvl: FW debug message level
117 */
118int hfi_set_debug_level(uint32_t lvl);
Lakshmi Narayana Kalavala85c40352017-05-15 16:19:13 -0700119
Suresh Vankadara6657bc22017-07-31 10:33:04 +0530120/**
121 * hfi_enable_ipe_bps_pc() - Enable interframe pc
122 * Host sends a command to firmware to enable interframe
123 * power collapse for IPE and BPS hardware.
124 *
125 * @enable: flag to enable/disable
Suresh Vankadara466bed22017-11-30 06:30:20 +0530126 * @core_info: Core information to firmware
Suresh Vankadara6657bc22017-07-31 10:33:04 +0530127 */
Suresh Vankadara466bed22017-11-30 06:30:20 +0530128int hfi_enable_ipe_bps_pc(bool enable, uint32_t core_info);
Suresh Vankadara6657bc22017-07-31 10:33:04 +0530129
Suresh Vankadaraaa6ff8f2017-10-26 22:51:27 +0530130/**
131 * hfi_cmd_ubwc_config() - UBWC configuration to firmware
132 * @ubwc_cfg: UBWC configuration parameters
133 */
134int hfi_cmd_ubwc_config(uint32_t *ubwc_cfg);
135
Suresh Vankadara466bed22017-11-30 06:30:20 +0530136/**
137 * cam_hfi_resume() - function to resume
138 * @hfi_mem: hfi memory info
139 * @icp_base: icp base address
140 * @debug: debug flag
141 *
142 * Returns success(zero)/failure(non zero)
143 */
144int cam_hfi_resume(struct hfi_mem_info *hfi_mem,
145 void __iomem *icp_base, bool debug);
146
Lakshmi Narayana Kalavala85c40352017-05-15 16:19:13 -0700147#endif /* _HFI_INTF_H_ */