2 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 #ifndef __SOC_TEGRA_BPMP_H
15 #define __SOC_TEGRA_BPMP_H
17 #include <linux/mailbox_client.h>
18 #include <linux/reset-controller.h>
19 #include <linux/semaphore.h>
20 #include <linux/types.h>
22 #include <soc/tegra/bpmp-abi.h>
24 struct tegra_bpmp_clk;
26 struct tegra_bpmp_soc {
32 } cpu_tx, thread, cpu_rx;
34 unsigned int num_resets;
37 struct tegra_bpmp_mb_data {
40 u8 data[MSG_DATA_MIN_SZ];
43 struct tegra_bpmp_channel {
44 struct tegra_bpmp *bpmp;
45 struct tegra_bpmp_mb_data *ib;
46 struct tegra_bpmp_mb_data *ob;
47 struct completion completion;
48 struct tegra_ivc *ivc;
51 typedef void (*tegra_bpmp_mrq_handler_t)(unsigned int mrq,
52 struct tegra_bpmp_channel *channel,
55 struct tegra_bpmp_mrq {
56 struct list_head list;
58 tegra_bpmp_mrq_handler_t handler;
63 const struct tegra_bpmp_soc *soc;
67 struct gen_pool *pool;
73 struct mbox_client client;
74 struct mbox_chan *channel;
77 struct tegra_bpmp_channel *channels;
78 unsigned int num_channels;
81 unsigned long *allocated;
84 struct semaphore lock;
87 struct list_head mrqs;
90 struct tegra_bpmp_clk **clocks;
91 unsigned int num_clocks;
93 struct reset_controller_dev rstc;
96 struct tegra_bpmp *tegra_bpmp_get(struct device *dev);
97 void tegra_bpmp_put(struct tegra_bpmp *bpmp);
99 struct tegra_bpmp_message {
113 int tegra_bpmp_transfer_atomic(struct tegra_bpmp *bpmp,
114 struct tegra_bpmp_message *msg);
115 int tegra_bpmp_transfer(struct tegra_bpmp *bpmp,
116 struct tegra_bpmp_message *msg);
118 int tegra_bpmp_request_mrq(struct tegra_bpmp *bpmp, unsigned int mrq,
119 tegra_bpmp_mrq_handler_t handler, void *data);
120 void tegra_bpmp_free_mrq(struct tegra_bpmp *bpmp, unsigned int mrq,
123 #if IS_ENABLED(CONFIG_CLK_TEGRA_BPMP)
124 int tegra_bpmp_init_clocks(struct tegra_bpmp *bpmp);
126 static inline int tegra_bpmp_init_clocks(struct tegra_bpmp *bpmp)
132 #if IS_ENABLED(CONFIG_RESET_TEGRA_BPMP)
133 int tegra_bpmp_init_resets(struct tegra_bpmp *bpmp);
135 static inline int tegra_bpmp_init_resets(struct tegra_bpmp *bpmp)
141 #endif /* __SOC_TEGRA_BPMP_H */