Lines Matching +full:ipa +full:- +full:shared

1 // SPDX-License-Identifier: GPL-2.0
3 /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
4 * Copyright (C) 2018-2020 Linaro Ltd.
12 #include "ipa.h"
16 * DOC: The IPA embedded microcontroller
18 * The IPA incorporates a microcontroller that is able to do some additional
28 * A 128 byte block of structured memory within the IPA SRAM is used together
30 * AP and the IPA microcontroller. Each side writes data to the shared area
32 * to the interrupt. Some information found in the shared area is currently
33 * unused. All remaining space in the shared area is reserved, and must not
42 * struct ipa_uc_mem_area - AP/microcontroller shared memory area
43 * @command: command code (AP->microcontroller)
45 * @command_param: low 32 bits of command parameter (AP->microcontroller)
46 * @command_param_hi: high 32 bits of command parameter (AP->microcontroller)
48 * @response: response code (microcontroller->AP)
50 * @response_param: response parameter (microcontroller->AP)
52 * @event: event code (microcontroller->AP)
54 * @event_param: event parameter (microcontroller->AP)
56 * @first_error_address: address of first error-source on SNOC
58 * @warning_counter: counter of non-fatal hardware errors
60 * @interface_version: hardware-reported interface version
63 * A shared memory area at the base of IPA resident memory is used for
87 /** enum ipa_uc_command - commands from the AP to the microcontroller */
102 /** enum ipa_uc_response - microcontroller response codes */
110 /** enum ipa_uc_event - common cpu events reported by the microcontroller */
117 static struct ipa_uc_mem_area *ipa_uc_shared(struct ipa *ipa) in ipa_uc_shared() argument
119 const struct ipa_mem *mem = ipa_mem_find(ipa, IPA_MEM_UC_SHARED); in ipa_uc_shared()
120 u32 offset = ipa->mem_offset + mem->offset; in ipa_uc_shared()
122 return ipa->mem_virt + offset; in ipa_uc_shared()
125 /* Microcontroller event IPA interrupt handler */
126 static void ipa_uc_event_handler(struct ipa *ipa, enum ipa_irq_id irq_id) in ipa_uc_event_handler() argument
128 struct ipa_uc_mem_area *shared = ipa_uc_shared(ipa); in ipa_uc_event_handler() local
129 struct device *dev = &ipa->pdev->dev; in ipa_uc_event_handler()
131 if (shared->event == IPA_UC_EVENT_ERROR) in ipa_uc_event_handler()
133 else if (shared->event != IPA_UC_EVENT_LOG_INFO) in ipa_uc_event_handler()
135 shared->event); in ipa_uc_event_handler()
139 /* Microcontroller response IPA interrupt handler */
140 static void ipa_uc_response_hdlr(struct ipa *ipa, enum ipa_irq_id irq_id) in ipa_uc_response_hdlr() argument
142 struct ipa_uc_mem_area *shared = ipa_uc_shared(ipa); in ipa_uc_response_hdlr() local
143 struct device *dev = &ipa->pdev->dev; in ipa_uc_response_hdlr()
153 switch (shared->response) { in ipa_uc_response_hdlr()
155 if (ipa->uc_powered) { in ipa_uc_response_hdlr()
156 ipa->uc_loaded = true; in ipa_uc_response_hdlr()
159 ipa->uc_powered = false; in ipa_uc_response_hdlr()
166 shared->response); in ipa_uc_response_hdlr()
171 /* Configure the IPA microcontroller subsystem */
172 void ipa_uc_config(struct ipa *ipa) in ipa_uc_config() argument
174 ipa->uc_powered = false; in ipa_uc_config()
175 ipa->uc_loaded = false; in ipa_uc_config()
176 ipa_interrupt_add(ipa->interrupt, IPA_IRQ_UC_0, ipa_uc_event_handler); in ipa_uc_config()
177 ipa_interrupt_add(ipa->interrupt, IPA_IRQ_UC_1, ipa_uc_response_hdlr); in ipa_uc_config()
181 void ipa_uc_deconfig(struct ipa *ipa) in ipa_uc_deconfig() argument
183 struct device *dev = &ipa->pdev->dev; in ipa_uc_deconfig()
185 ipa_interrupt_remove(ipa->interrupt, IPA_IRQ_UC_1); in ipa_uc_deconfig()
186 ipa_interrupt_remove(ipa->interrupt, IPA_IRQ_UC_0); in ipa_uc_deconfig()
187 if (!ipa->uc_powered) in ipa_uc_deconfig()
195 void ipa_uc_power(struct ipa *ipa) in ipa_uc_power() argument
206 dev = &ipa->pdev->dev; in ipa_uc_power()
212 ipa->uc_powered = true; in ipa_uc_power()
217 static void send_uc_command(struct ipa *ipa, u32 command, u32 command_param) in send_uc_command() argument
219 struct ipa_uc_mem_area *shared = ipa_uc_shared(ipa); in send_uc_command() local
224 shared->command = command; in send_uc_command()
225 shared->command_param = cpu_to_le32(command_param); in send_uc_command()
226 shared->command_param_hi = 0; in send_uc_command()
227 shared->response = 0; in send_uc_command()
228 shared->response_param = 0; in send_uc_command()
232 offset = ipa_reg_irq_uc_offset(ipa->version); in send_uc_command()
233 iowrite32(val, ipa->reg_virt + offset); in send_uc_command()
237 void ipa_uc_panic_notifier(struct ipa *ipa) in ipa_uc_panic_notifier() argument
239 if (!ipa->uc_loaded) in ipa_uc_panic_notifier()
242 send_uc_command(ipa, IPA_UC_COMMAND_ERR_FATAL, 0); in ipa_uc_panic_notifier()