1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
6 #ifndef __SOC_TEGRA_BPMP_H
7 #define __SOC_TEGRA_BPMP_H
9 #include <linux/mailbox_client.h>
10 #include <linux/pm_domain.h>
11 #include <linux/reset-controller.h>
12 #include <linux/semaphore.h>
13 #include <linux/types.h>
15 #include <soc/tegra/bpmp-abi.h>
17 struct tegra_bpmp_clk
;
18 struct tegra_bpmp_ops
;
20 struct tegra_bpmp_soc
{
26 } cpu_tx
, thread
, cpu_rx
;
29 const struct tegra_bpmp_ops
*ops
;
30 unsigned int num_resets
;
33 struct tegra_bpmp_mb_data
{
36 u8 data
[MSG_DATA_MIN_SZ
];
39 struct tegra_bpmp_channel
{
40 struct tegra_bpmp
*bpmp
;
41 struct tegra_bpmp_mb_data
*ib
;
42 struct tegra_bpmp_mb_data
*ob
;
43 struct completion completion
;
44 struct tegra_ivc
*ivc
;
48 typedef void (*tegra_bpmp_mrq_handler_t
)(unsigned int mrq
,
49 struct tegra_bpmp_channel
*channel
,
52 struct tegra_bpmp_mrq
{
53 struct list_head list
;
55 tegra_bpmp_mrq_handler_t handler
;
60 const struct tegra_bpmp_soc
*soc
;
65 struct mbox_client client
;
66 struct mbox_chan
*channel
;
69 spinlock_t atomic_tx_lock
;
70 struct tegra_bpmp_channel
*tx_channel
, *rx_channel
, *threaded_channels
;
73 unsigned long *allocated
;
76 struct semaphore lock
;
79 struct list_head mrqs
;
82 struct tegra_bpmp_clk
**clocks
;
83 unsigned int num_clocks
;
85 struct reset_controller_dev rstc
;
87 struct genpd_onecell_data genpd
;
89 #ifdef CONFIG_DEBUG_FS
90 struct dentry
*debugfs_mirror
;
94 struct tegra_bpmp_message
{
109 #if IS_ENABLED(CONFIG_TEGRA_BPMP)
110 struct tegra_bpmp
*tegra_bpmp_get(struct device
*dev
);
111 void tegra_bpmp_put(struct tegra_bpmp
*bpmp
);
112 int tegra_bpmp_transfer_atomic(struct tegra_bpmp
*bpmp
,
113 struct tegra_bpmp_message
*msg
);
114 int tegra_bpmp_transfer(struct tegra_bpmp
*bpmp
,
115 struct tegra_bpmp_message
*msg
);
116 void tegra_bpmp_mrq_return(struct tegra_bpmp_channel
*channel
, int code
,
117 const void *data
, size_t size
);
119 int tegra_bpmp_request_mrq(struct tegra_bpmp
*bpmp
, unsigned int mrq
,
120 tegra_bpmp_mrq_handler_t handler
, void *data
);
121 void tegra_bpmp_free_mrq(struct tegra_bpmp
*bpmp
, unsigned int mrq
,
123 bool tegra_bpmp_mrq_is_supported(struct tegra_bpmp
*bpmp
, unsigned int mrq
);
125 static inline struct tegra_bpmp
*tegra_bpmp_get(struct device
*dev
)
127 return ERR_PTR(-ENOTSUPP
);
129 static inline void tegra_bpmp_put(struct tegra_bpmp
*bpmp
)
132 static inline int tegra_bpmp_transfer_atomic(struct tegra_bpmp
*bpmp
,
133 struct tegra_bpmp_message
*msg
)
137 static inline int tegra_bpmp_transfer(struct tegra_bpmp
*bpmp
,
138 struct tegra_bpmp_message
*msg
)
142 static inline void tegra_bpmp_mrq_return(struct tegra_bpmp_channel
*channel
,
143 int code
, const void *data
,
148 static inline int tegra_bpmp_request_mrq(struct tegra_bpmp
*bpmp
,
150 tegra_bpmp_mrq_handler_t handler
,
155 static inline void tegra_bpmp_free_mrq(struct tegra_bpmp
*bpmp
,
156 unsigned int mrq
, void *data
)
160 static inline bool tegra_bpmp_mrq_is_supported(struct tegra_bpmp
*bpmp
,
167 void tegra_bpmp_handle_rx(struct tegra_bpmp
*bpmp
);
169 #if IS_ENABLED(CONFIG_CLK_TEGRA_BPMP)
170 int tegra_bpmp_init_clocks(struct tegra_bpmp
*bpmp
);
172 static inline int tegra_bpmp_init_clocks(struct tegra_bpmp
*bpmp
)
178 #if IS_ENABLED(CONFIG_RESET_TEGRA_BPMP)
179 int tegra_bpmp_init_resets(struct tegra_bpmp
*bpmp
);
181 static inline int tegra_bpmp_init_resets(struct tegra_bpmp
*bpmp
)
187 #if IS_ENABLED(CONFIG_SOC_TEGRA_POWERGATE_BPMP)
188 int tegra_bpmp_init_powergates(struct tegra_bpmp
*bpmp
);
190 static inline int tegra_bpmp_init_powergates(struct tegra_bpmp
*bpmp
)
196 #if IS_ENABLED(CONFIG_DEBUG_FS)
197 int tegra_bpmp_init_debugfs(struct tegra_bpmp
*bpmp
);
199 static inline int tegra_bpmp_init_debugfs(struct tegra_bpmp
*bpmp
)
206 #endif /* __SOC_TEGRA_BPMP_H */