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-2022 Linaro Ltd.
12 #include "ipa.h"
17 * DOC: The IPA embedded microcontroller
19 * The IPA incorporates a microcontroller that is able to do some additional
29 * A 128 byte block of structured memory within the IPA SRAM is used together
31 * AP and the IPA microcontroller. Each side writes data to the shared area
43 * struct ipa_uc_mem_area - AP/microcontroller shared memory area
44 * @command: command code (AP->microcontroller)
46 * @command_param: low 32 bits of command parameter (AP->microcontroller)
47 * @command_param_hi: high 32 bits of command parameter (AP->microcontroller)
49 * @response: response code (microcontroller->AP)
51 * @response_param: response parameter (microcontroller->AP)
53 * @event: event code (microcontroller->AP)
55 * @event_param: event parameter (microcontroller->AP)
57 * @first_error_address: address of first error-source on SNOC
59 * @warning_counter: counter of non-fatal hardware errors
61 * @interface_version: hardware-reported interface version
64 * A shared memory area at the base of IPA resident memory is used for
88 /** enum ipa_uc_command - commands from the AP to the microcontroller */
103 /** enum ipa_uc_response - microcontroller response codes */
111 /** enum ipa_uc_event - common cpu events reported by the microcontroller */
118 static struct ipa_uc_mem_area *ipa_uc_shared(struct ipa *ipa) in ipa_uc_shared() argument
120 const struct ipa_mem *mem = ipa_mem_find(ipa, IPA_MEM_UC_SHARED); in ipa_uc_shared()
121 u32 offset = ipa->mem_offset + mem->offset; in ipa_uc_shared()
123 return ipa->mem_virt + offset; in ipa_uc_shared()
126 /* Microcontroller event IPA interrupt handler */
127 static void ipa_uc_event_handler(struct ipa *ipa) in ipa_uc_event_handler() argument
129 struct ipa_uc_mem_area *shared = ipa_uc_shared(ipa); in ipa_uc_event_handler()
130 struct device *dev = &ipa->pdev->dev; in ipa_uc_event_handler()
132 if (shared->event == IPA_UC_EVENT_ERROR) in ipa_uc_event_handler()
134 else if (shared->event != IPA_UC_EVENT_LOG_INFO) in ipa_uc_event_handler()
136 shared->event); in ipa_uc_event_handler()
140 /* Microcontroller response IPA interrupt handler */
141 static void ipa_uc_response_hdlr(struct ipa *ipa) in ipa_uc_response_hdlr() argument
143 struct ipa_uc_mem_area *shared = ipa_uc_shared(ipa); in ipa_uc_response_hdlr()
144 struct device *dev = &ipa->pdev->dev; in ipa_uc_response_hdlr()
154 switch (shared->response) { in ipa_uc_response_hdlr()
156 if (ipa->uc_powered) { in ipa_uc_response_hdlr()
157 ipa->uc_loaded = true; in ipa_uc_response_hdlr()
158 ipa_power_retention(ipa, true); in ipa_uc_response_hdlr()
161 ipa->uc_powered = false; in ipa_uc_response_hdlr()
168 shared->response); in ipa_uc_response_hdlr()
173 void ipa_uc_interrupt_handler(struct ipa *ipa, enum ipa_irq_id irq_id) in ipa_uc_interrupt_handler() argument
177 ipa_uc_event_handler(ipa); in ipa_uc_interrupt_handler()
179 ipa_uc_response_hdlr(ipa); in ipa_uc_interrupt_handler()
182 /* Configure the IPA microcontroller subsystem */
183 void ipa_uc_config(struct ipa *ipa) in ipa_uc_config() argument
185 ipa->uc_powered = false; in ipa_uc_config()
186 ipa->uc_loaded = false; in ipa_uc_config()
187 ipa_interrupt_enable(ipa, IPA_IRQ_UC_0); in ipa_uc_config()
188 ipa_interrupt_enable(ipa, IPA_IRQ_UC_1); in ipa_uc_config()
192 void ipa_uc_deconfig(struct ipa *ipa) in ipa_uc_deconfig() argument
194 struct device *dev = &ipa->pdev->dev; in ipa_uc_deconfig()
196 ipa_interrupt_disable(ipa, IPA_IRQ_UC_1); in ipa_uc_deconfig()
197 ipa_interrupt_disable(ipa, IPA_IRQ_UC_0); in ipa_uc_deconfig()
198 if (ipa->uc_loaded) in ipa_uc_deconfig()
199 ipa_power_retention(ipa, false); in ipa_uc_deconfig()
201 if (!ipa->uc_powered) in ipa_uc_deconfig()
209 void ipa_uc_power(struct ipa *ipa) in ipa_uc_power() argument
220 dev = &ipa->pdev->dev; in ipa_uc_power()
226 ipa->uc_powered = true; in ipa_uc_power()
231 static void send_uc_command(struct ipa *ipa, u32 command, u32 command_param) in send_uc_command() argument
233 struct ipa_uc_mem_area *shared = ipa_uc_shared(ipa); in send_uc_command()
234 const struct reg *reg; in send_uc_command() local
238 shared->command = command; in send_uc_command()
239 shared->command_param = cpu_to_le32(command_param); in send_uc_command()
240 shared->command_param_hi = 0; in send_uc_command()
241 shared->response = 0; in send_uc_command()
242 shared->response_param = 0; in send_uc_command()
245 reg = ipa_reg(ipa, IPA_IRQ_UC); in send_uc_command()
246 val = reg_bit(reg, UC_INTR); in send_uc_command()
248 iowrite32(val, ipa->reg_virt + reg_offset(reg)); in send_uc_command()
252 void ipa_uc_panic_notifier(struct ipa *ipa) in ipa_uc_panic_notifier() argument
254 if (!ipa->uc_loaded) in ipa_uc_panic_notifier()
257 send_uc_command(ipa, IPA_UC_COMMAND_ERR_FATAL, 0); in ipa_uc_panic_notifier()