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/pm_domain.h>
19 #include <linux/reset-controller.h>
20 #include <linux/semaphore.h>
21 #include <linux/types.h>
23 #include <soc/tegra/bpmp-abi.h>
25 struct tegra_bpmp_clk
;
26 struct tegra_bpmp_ops
;
28 struct tegra_bpmp_soc
{
34 } cpu_tx
, thread
, cpu_rx
;
37 const struct tegra_bpmp_ops
*ops
;
38 unsigned int num_resets
;
41 struct tegra_bpmp_mb_data
{
44 u8 data
[MSG_DATA_MIN_SZ
];
47 struct tegra_bpmp_channel
{
48 struct tegra_bpmp
*bpmp
;
49 struct tegra_bpmp_mb_data
*ib
;
50 struct tegra_bpmp_mb_data
*ob
;
51 struct completion completion
;
52 struct tegra_ivc
*ivc
;
56 typedef void (*tegra_bpmp_mrq_handler_t
)(unsigned int mrq
,
57 struct tegra_bpmp_channel
*channel
,
60 struct tegra_bpmp_mrq
{
61 struct list_head list
;
63 tegra_bpmp_mrq_handler_t handler
;
68 const struct tegra_bpmp_soc
*soc
;
73 struct mbox_client client
;
74 struct mbox_chan
*channel
;
77 spinlock_t atomic_tx_lock
;
78 struct tegra_bpmp_channel
*tx_channel
, *rx_channel
, *threaded_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
;
95 struct genpd_onecell_data genpd
;
97 #ifdef CONFIG_DEBUG_FS
98 struct dentry
*debugfs_mirror
;
102 struct tegra_bpmp_message
{
117 #if IS_ENABLED(CONFIG_TEGRA_BPMP)
118 struct tegra_bpmp
*tegra_bpmp_get(struct device
*dev
);
119 void tegra_bpmp_put(struct tegra_bpmp
*bpmp
);
120 int tegra_bpmp_transfer_atomic(struct tegra_bpmp
*bpmp
,
121 struct tegra_bpmp_message
*msg
);
122 int tegra_bpmp_transfer(struct tegra_bpmp
*bpmp
,
123 struct tegra_bpmp_message
*msg
);
124 void tegra_bpmp_mrq_return(struct tegra_bpmp_channel
*channel
, int code
,
125 const void *data
, size_t size
);
127 int tegra_bpmp_request_mrq(struct tegra_bpmp
*bpmp
, unsigned int mrq
,
128 tegra_bpmp_mrq_handler_t handler
, void *data
);
129 void tegra_bpmp_free_mrq(struct tegra_bpmp
*bpmp
, unsigned int mrq
,
131 bool tegra_bpmp_mrq_is_supported(struct tegra_bpmp
*bpmp
, unsigned int mrq
);
133 static inline struct tegra_bpmp
*tegra_bpmp_get(struct device
*dev
)
135 return ERR_PTR(-ENOTSUPP
);
137 static inline void tegra_bpmp_put(struct tegra_bpmp
*bpmp
)
140 static inline int tegra_bpmp_transfer_atomic(struct tegra_bpmp
*bpmp
,
141 struct tegra_bpmp_message
*msg
)
145 static inline int tegra_bpmp_transfer(struct tegra_bpmp
*bpmp
,
146 struct tegra_bpmp_message
*msg
)
150 static inline void tegra_bpmp_mrq_return(struct tegra_bpmp_channel
*channel
,
151 int code
, const void *data
,
156 static inline int tegra_bpmp_request_mrq(struct tegra_bpmp
*bpmp
,
158 tegra_bpmp_mrq_handler_t handler
,
163 static inline void tegra_bpmp_free_mrq(struct tegra_bpmp
*bpmp
,
164 unsigned int mrq
, void *data
)
168 static inline bool tegra_bpmp_mrq_is_supported(struct tegra_bpmp
*bpmp
,
175 void tegra_bpmp_handle_rx(struct tegra_bpmp
*bpmp
);
177 #if IS_ENABLED(CONFIG_CLK_TEGRA_BPMP)
178 int tegra_bpmp_init_clocks(struct tegra_bpmp
*bpmp
);
180 static inline int tegra_bpmp_init_clocks(struct tegra_bpmp
*bpmp
)
186 #if IS_ENABLED(CONFIG_RESET_TEGRA_BPMP)
187 int tegra_bpmp_init_resets(struct tegra_bpmp
*bpmp
);
189 static inline int tegra_bpmp_init_resets(struct tegra_bpmp
*bpmp
)
195 #if IS_ENABLED(CONFIG_SOC_TEGRA_POWERGATE_BPMP)
196 int tegra_bpmp_init_powergates(struct tegra_bpmp
*bpmp
);
198 static inline int tegra_bpmp_init_powergates(struct tegra_bpmp
*bpmp
)
204 #if IS_ENABLED(CONFIG_DEBUG_FS)
205 int tegra_bpmp_init_debugfs(struct tegra_bpmp
*bpmp
);
207 static inline int tegra_bpmp_init_debugfs(struct tegra_bpmp
*bpmp
)
214 #endif /* __SOC_TEGRA_BPMP_H */