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.
11 #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 u32 offset = ipa->mem_offset + ipa->mem[IPA_MEM_UC_SHARED].offset; in ipa_uc_shared()
121 return ipa->mem_virt + offset; in ipa_uc_shared()
124 /* Microcontroller event IPA interrupt handler */
125 static void ipa_uc_event_handler(struct ipa *ipa, enum ipa_irq_id irq_id) in ipa_uc_event_handler() argument
127 struct ipa_uc_mem_area *shared = ipa_uc_shared(ipa); in ipa_uc_event_handler() local
128 struct device *dev = &ipa->pdev->dev; in ipa_uc_event_handler()
130 if (shared->event == IPA_UC_EVENT_ERROR) in ipa_uc_event_handler()
134 shared->event); in ipa_uc_event_handler()
137 /* Microcontroller response IPA interrupt handler */
138 static void ipa_uc_response_hdlr(struct ipa *ipa, enum ipa_irq_id irq_id) in ipa_uc_response_hdlr() argument
140 struct ipa_uc_mem_area *shared = ipa_uc_shared(ipa); in ipa_uc_response_hdlr() local
150 switch (shared->response) { in ipa_uc_response_hdlr()
152 ipa->uc_loaded = true; in ipa_uc_response_hdlr()
153 ipa_clock_put(ipa); in ipa_uc_response_hdlr()
156 dev_warn(&ipa->pdev->dev, in ipa_uc_response_hdlr()
158 shared->response); in ipa_uc_response_hdlr()
163 /* ipa_uc_setup() - Set up the microcontroller */
164 void ipa_uc_setup(struct ipa *ipa) in ipa_uc_setup() argument
166 /* The microcontroller needs the IPA clock running until it has in ipa_uc_setup()
169 * we have finished doing the rest of the IPA initialization, so we in ipa_uc_setup()
174 ipa_clock_get(ipa); in ipa_uc_setup()
176 ipa->uc_loaded = false; in ipa_uc_setup()
177 ipa_interrupt_add(ipa->interrupt, IPA_IRQ_UC_0, ipa_uc_event_handler); in ipa_uc_setup()
178 ipa_interrupt_add(ipa->interrupt, IPA_IRQ_UC_1, ipa_uc_response_hdlr); in ipa_uc_setup()
182 void ipa_uc_teardown(struct ipa *ipa) in ipa_uc_teardown() argument
184 ipa_interrupt_remove(ipa->interrupt, IPA_IRQ_UC_1); in ipa_uc_teardown()
185 ipa_interrupt_remove(ipa->interrupt, IPA_IRQ_UC_0); in ipa_uc_teardown()
186 if (!ipa->uc_loaded) in ipa_uc_teardown()
187 ipa_clock_put(ipa); in ipa_uc_teardown()
191 static void send_uc_command(struct ipa *ipa, u32 command, u32 command_param) in send_uc_command() argument
193 struct ipa_uc_mem_area *shared = ipa_uc_shared(ipa); in send_uc_command() local
195 shared->command = command; in send_uc_command()
196 shared->command_param = cpu_to_le32(command_param); in send_uc_command()
197 shared->command_param_hi = 0; in send_uc_command()
198 shared->response = 0; in send_uc_command()
199 shared->response_param = 0; in send_uc_command()
201 iowrite32(1, ipa->reg_virt + IPA_REG_IRQ_UC_OFFSET); in send_uc_command()
205 void ipa_uc_panic_notifier(struct ipa *ipa) in ipa_uc_panic_notifier() argument
207 if (!ipa->uc_loaded) in ipa_uc_panic_notifier()
210 send_uc_command(ipa, IPA_UC_COMMAND_ERR_FATAL, 0); in ipa_uc_panic_notifier()