Lines Matching full:bpmp
12 #include <soc/tegra/bpmp.h>
13 #include <soc/tegra/bpmp-abi.h>
16 #include "bpmp-private.h"
82 static int tegra186_bpmp_ring_doorbell(struct tegra_bpmp *bpmp) in tegra186_bpmp_ring_doorbell() argument
84 struct tegra186_bpmp *priv = bpmp->priv; in tegra186_bpmp_ring_doorbell()
98 struct tegra_bpmp *bpmp = data; in tegra186_bpmp_ivc_notify() local
99 struct tegra186_bpmp *priv = bpmp->priv; in tegra186_bpmp_ivc_notify()
104 tegra186_bpmp_ring_doorbell(bpmp); in tegra186_bpmp_ivc_notify()
108 struct tegra_bpmp *bpmp, in tegra186_bpmp_channel_init() argument
111 struct tegra186_bpmp *priv = bpmp->priv; in tegra186_bpmp_channel_init()
117 channel->ivc = devm_kzalloc(bpmp->dev, sizeof(*channel->ivc), in tegra186_bpmp_channel_init()
136 bpmp); in tegra186_bpmp_channel_init()
138 dev_err(bpmp->dev, "failed to setup IVC for channel %u: %d\n", in tegra186_bpmp_channel_init()
144 channel->bpmp = bpmp; in tegra186_bpmp_channel_init()
154 /* sync the channel state with BPMP */ in tegra186_bpmp_channel_reset()
166 struct tegra_bpmp *bpmp = mbox_client_to_bpmp(client); in mbox_handle_rx() local
168 tegra_bpmp_handle_rx(bpmp); in mbox_handle_rx()
171 static void tegra186_bpmp_teardown_channels(struct tegra_bpmp *bpmp) in tegra186_bpmp_teardown_channels() argument
173 struct tegra186_bpmp *priv = bpmp->priv; in tegra186_bpmp_teardown_channels()
176 for (i = 0; i < bpmp->threaded.count; i++) { in tegra186_bpmp_teardown_channels()
177 if (!bpmp->threaded_channels[i].bpmp) in tegra186_bpmp_teardown_channels()
180 tegra186_bpmp_channel_cleanup(&bpmp->threaded_channels[i]); in tegra186_bpmp_teardown_channels()
183 tegra186_bpmp_channel_cleanup(bpmp->rx_channel); in tegra186_bpmp_teardown_channels()
184 tegra186_bpmp_channel_cleanup(bpmp->tx_channel); in tegra186_bpmp_teardown_channels()
192 static int tegra186_bpmp_dram_init(struct tegra_bpmp *bpmp) in tegra186_bpmp_dram_init() argument
194 struct tegra186_bpmp *priv = bpmp->priv; in tegra186_bpmp_dram_init()
200 np = of_parse_phandle(bpmp->dev->of_node, "memory-region", 0); in tegra186_bpmp_dram_init()
206 dev_warn(bpmp->dev, "failed to parse memory region: %d\n", err); in tegra186_bpmp_dram_init()
213 dev_warn(bpmp->dev, "DRAM region must be larger than 8 KiB\n"); in tegra186_bpmp_dram_init()
220 priv->tx.dram = devm_memremap(bpmp->dev, priv->tx.phys, size, in tegra186_bpmp_dram_init()
224 dev_warn(bpmp->dev, "failed to map DRAM region: %d\n", err); in tegra186_bpmp_dram_init()
233 static int tegra186_bpmp_sram_init(struct tegra_bpmp *bpmp) in tegra186_bpmp_sram_init() argument
235 struct tegra186_bpmp *priv = bpmp->priv; in tegra186_bpmp_sram_init()
238 priv->tx.pool = of_gen_pool_get(bpmp->dev->of_node, "shmem", 0); in tegra186_bpmp_sram_init()
240 dev_err(bpmp->dev, "TX shmem pool not found\n"); in tegra186_bpmp_sram_init()
247 dev_err(bpmp->dev, "failed to allocate from TX pool\n"); in tegra186_bpmp_sram_init()
251 priv->rx.pool = of_gen_pool_get(bpmp->dev->of_node, "shmem", 1); in tegra186_bpmp_sram_init()
253 dev_err(bpmp->dev, "RX shmem pool not found\n"); in tegra186_bpmp_sram_init()
261 dev_err(bpmp->dev, "failed to allocate from RX pool\n"); in tegra186_bpmp_sram_init()
274 static int tegra186_bpmp_setup_channels(struct tegra_bpmp *bpmp) in tegra186_bpmp_setup_channels() argument
279 err = tegra186_bpmp_dram_init(bpmp); in tegra186_bpmp_setup_channels()
281 err = tegra186_bpmp_sram_init(bpmp); in tegra186_bpmp_setup_channels()
286 err = tegra186_bpmp_channel_init(bpmp->tx_channel, bpmp, in tegra186_bpmp_setup_channels()
287 bpmp->soc->channels.cpu_tx.offset); in tegra186_bpmp_setup_channels()
291 err = tegra186_bpmp_channel_init(bpmp->rx_channel, bpmp, in tegra186_bpmp_setup_channels()
292 bpmp->soc->channels.cpu_rx.offset); in tegra186_bpmp_setup_channels()
294 tegra186_bpmp_channel_cleanup(bpmp->tx_channel); in tegra186_bpmp_setup_channels()
298 for (i = 0; i < bpmp->threaded.count; i++) { in tegra186_bpmp_setup_channels()
299 unsigned int index = bpmp->soc->channels.thread.offset + i; in tegra186_bpmp_setup_channels()
301 err = tegra186_bpmp_channel_init(&bpmp->threaded_channels[i], in tegra186_bpmp_setup_channels()
302 bpmp, index); in tegra186_bpmp_setup_channels()
308 tegra186_bpmp_teardown_channels(bpmp); in tegra186_bpmp_setup_channels()
313 static void tegra186_bpmp_reset_channels(struct tegra_bpmp *bpmp) in tegra186_bpmp_reset_channels() argument
318 tegra186_bpmp_channel_reset(bpmp->tx_channel); in tegra186_bpmp_reset_channels()
319 tegra186_bpmp_channel_reset(bpmp->rx_channel); in tegra186_bpmp_reset_channels()
321 for (i = 0; i < bpmp->threaded.count; i++) in tegra186_bpmp_reset_channels()
322 tegra186_bpmp_channel_reset(&bpmp->threaded_channels[i]); in tegra186_bpmp_reset_channels()
325 static int tegra186_bpmp_init(struct tegra_bpmp *bpmp) in tegra186_bpmp_init() argument
330 priv = devm_kzalloc(bpmp->dev, sizeof(*priv), GFP_KERNEL); in tegra186_bpmp_init()
334 priv->parent = bpmp; in tegra186_bpmp_init()
335 bpmp->priv = priv; in tegra186_bpmp_init()
337 err = tegra186_bpmp_setup_channels(bpmp); in tegra186_bpmp_init()
342 priv->mbox.client.dev = bpmp->dev; in tegra186_bpmp_init()
350 dev_err(bpmp->dev, "failed to get HSP mailbox: %d\n", err); in tegra186_bpmp_init()
351 tegra186_bpmp_teardown_channels(bpmp); in tegra186_bpmp_init()
355 tegra186_bpmp_reset_channels(bpmp); in tegra186_bpmp_init()
360 static void tegra186_bpmp_deinit(struct tegra_bpmp *bpmp) in tegra186_bpmp_deinit() argument
362 struct tegra186_bpmp *priv = bpmp->priv; in tegra186_bpmp_deinit()
366 tegra186_bpmp_teardown_channels(bpmp); in tegra186_bpmp_deinit()
369 static int tegra186_bpmp_resume(struct tegra_bpmp *bpmp) in tegra186_bpmp_resume() argument
371 tegra186_bpmp_reset_channels(bpmp); in tegra186_bpmp_resume()