Lines Matching +full:ipa +full:- +full:reg
1 // SPDX-License-Identifier: GPL-2.0
3 /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
4 * Copyright (C) 2018-2024 Linaro Ltd.
12 #include "ipa.h"
19 * DOC: The IPA embedded microcontroller
21 * The IPA incorporates a microcontroller that is able to do some additional
31 * A 128 byte block of structured memory within the IPA SRAM is used together
33 * AP and the IPA microcontroller. Each side writes data to the shared area
45 * struct ipa_uc_mem_area - AP/microcontroller shared memory area
46 * @command: command code (AP->microcontroller)
48 * @command_param: low 32 bits of command parameter (AP->microcontroller)
49 * @command_param_hi: high 32 bits of command parameter (AP->microcontroller)
51 * @response: response code (microcontroller->AP)
53 * @response_param: response parameter (microcontroller->AP)
55 * @event: event code (microcontroller->AP)
57 * @event_param: event parameter (microcontroller->AP)
59 * @first_error_address: address of first error-source on SNOC
61 * @warning_counter: counter of non-fatal hardware errors
63 * @interface_version: hardware-reported interface version
66 * A shared memory area at the base of IPA resident memory is used for
90 /** enum ipa_uc_command - commands from the AP to the microcontroller */
105 /** enum ipa_uc_response - microcontroller response codes */
113 /** enum ipa_uc_event - common cpu events reported by the microcontroller */
120 static struct ipa_uc_mem_area *ipa_uc_shared(struct ipa *ipa) in ipa_uc_shared() argument
122 const struct ipa_mem *mem = ipa_mem_find(ipa, IPA_MEM_UC_SHARED); in ipa_uc_shared()
123 u32 offset = ipa->mem_offset + mem->offset; in ipa_uc_shared()
125 return ipa->mem_virt + offset; in ipa_uc_shared()
128 /* Microcontroller event IPA interrupt handler */
129 static void ipa_uc_event_handler(struct ipa *ipa) in ipa_uc_event_handler() argument
131 struct ipa_uc_mem_area *shared = ipa_uc_shared(ipa); in ipa_uc_event_handler()
132 struct device *dev = ipa->dev; in ipa_uc_event_handler()
134 if (shared->event == IPA_UC_EVENT_ERROR) in ipa_uc_event_handler()
136 else if (shared->event != IPA_UC_EVENT_LOG_INFO) in ipa_uc_event_handler()
138 shared->event); in ipa_uc_event_handler()
142 /* Microcontroller response IPA interrupt handler */
143 static void ipa_uc_response_hdlr(struct ipa *ipa) in ipa_uc_response_hdlr() argument
145 struct ipa_uc_mem_area *shared = ipa_uc_shared(ipa); in ipa_uc_response_hdlr()
146 struct device *dev = ipa->dev; in ipa_uc_response_hdlr()
156 switch (shared->response) { in ipa_uc_response_hdlr()
158 if (ipa->uc_powered) { in ipa_uc_response_hdlr()
159 ipa->uc_loaded = true; in ipa_uc_response_hdlr()
160 ipa_power_retention(ipa, true); in ipa_uc_response_hdlr()
163 ipa->uc_powered = false; in ipa_uc_response_hdlr()
170 shared->response); in ipa_uc_response_hdlr()
175 void ipa_uc_interrupt_handler(struct ipa *ipa, enum ipa_irq_id irq_id) in ipa_uc_interrupt_handler() argument
179 ipa_uc_event_handler(ipa); in ipa_uc_interrupt_handler()
181 ipa_uc_response_hdlr(ipa); in ipa_uc_interrupt_handler()
184 /* Configure the IPA microcontroller subsystem */
185 void ipa_uc_config(struct ipa *ipa) in ipa_uc_config() argument
187 ipa->uc_powered = false; in ipa_uc_config()
188 ipa->uc_loaded = false; in ipa_uc_config()
189 ipa_interrupt_enable(ipa, IPA_IRQ_UC_0); in ipa_uc_config()
190 ipa_interrupt_enable(ipa, IPA_IRQ_UC_1); in ipa_uc_config()
194 void ipa_uc_deconfig(struct ipa *ipa) in ipa_uc_deconfig() argument
196 struct device *dev = ipa->dev; in ipa_uc_deconfig()
198 ipa_interrupt_disable(ipa, IPA_IRQ_UC_1); in ipa_uc_deconfig()
199 ipa_interrupt_disable(ipa, IPA_IRQ_UC_0); in ipa_uc_deconfig()
200 if (ipa->uc_loaded) in ipa_uc_deconfig()
201 ipa_power_retention(ipa, false); in ipa_uc_deconfig()
203 if (!ipa->uc_powered) in ipa_uc_deconfig()
211 void ipa_uc_power(struct ipa *ipa) in ipa_uc_power() argument
213 struct device *dev = ipa->dev; in ipa_uc_power()
227 ipa->uc_powered = true; in ipa_uc_power()
232 static void send_uc_command(struct ipa *ipa, u32 command, u32 command_param) in send_uc_command() argument
234 struct ipa_uc_mem_area *shared = ipa_uc_shared(ipa); in send_uc_command()
235 const struct reg *reg; in send_uc_command() local
239 shared->command = command; in send_uc_command()
240 shared->command_param = cpu_to_le32(command_param); in send_uc_command()
241 shared->command_param_hi = 0; in send_uc_command()
242 shared->response = 0; in send_uc_command()
243 shared->response_param = 0; in send_uc_command()
246 reg = ipa_reg(ipa, IPA_IRQ_UC); in send_uc_command()
247 val = reg_bit(reg, UC_INTR); in send_uc_command()
249 iowrite32(val, ipa->reg_virt + reg_offset(reg)); in send_uc_command()
253 void ipa_uc_panic_notifier(struct ipa *ipa) in ipa_uc_panic_notifier() argument
255 if (!ipa->uc_loaded) in ipa_uc_panic_notifier()
258 send_uc_command(ipa, IPA_UC_COMMAND_ERR_FATAL, 0); in ipa_uc_panic_notifier()