Linux Audio

Check our new training course

Loading...
v4.10.11
 
  1/*
  2 * Copyright (c) 2016, NVIDIA CORPORATION.  All rights reserved.
  3 *
  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.
  7 *
  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
 11 * more details.
 12 */
 13
 14#ifndef __SOC_TEGRA_BPMP_H
 15#define __SOC_TEGRA_BPMP_H
 16
 
 17#include <linux/mailbox_client.h>
 
 18#include <linux/reset-controller.h>
 19#include <linux/semaphore.h>
 20#include <linux/types.h>
 21
 22#include <soc/tegra/bpmp-abi.h>
 23
 24struct tegra_bpmp_clk;
 
 25
 26struct tegra_bpmp_soc {
 27	struct {
 28		struct {
 29			unsigned int offset;
 30			unsigned int count;
 31			unsigned int timeout;
 32		} cpu_tx, thread, cpu_rx;
 33	} channels;
 
 
 34	unsigned int num_resets;
 35};
 36
 37struct tegra_bpmp_mb_data {
 38	u32 code;
 39	u32 flags;
 40	u8 data[MSG_DATA_MIN_SZ];
 41} __packed;
 42
 
 
 
 
 
 
 
 
 
 
 
 
 43struct 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;
 
 49};
 50
 51typedef void (*tegra_bpmp_mrq_handler_t)(unsigned int mrq,
 52					 struct tegra_bpmp_channel *channel,
 53					 void *data);
 54
 55struct tegra_bpmp_mrq {
 56	struct list_head list;
 57	unsigned int mrq;
 58	tegra_bpmp_mrq_handler_t handler;
 59	void *data;
 60};
 61
 62struct tegra_bpmp {
 63	const struct tegra_bpmp_soc *soc;
 64	struct device *dev;
 65
 66	struct {
 67		struct gen_pool *pool;
 68		dma_addr_t phys;
 69		void *virt;
 70	} tx, rx;
 71
 72	struct {
 73		struct mbox_client client;
 74		struct mbox_chan *channel;
 75	} mbox;
 76
 77	struct tegra_bpmp_channel *channels;
 78	unsigned int num_channels;
 79
 80	struct {
 81		unsigned long *allocated;
 82		unsigned long *busy;
 83		unsigned int count;
 84		struct semaphore lock;
 85	} threaded;
 86
 87	struct list_head mrqs;
 88	spinlock_t lock;
 89
 90	struct tegra_bpmp_clk **clocks;
 91	unsigned int num_clocks;
 92
 93	struct reset_controller_dev rstc;
 
 
 
 
 
 
 
 
 94};
 95
 96struct tegra_bpmp *tegra_bpmp_get(struct device *dev);
 97void tegra_bpmp_put(struct tegra_bpmp *bpmp);
 98
 99struct tegra_bpmp_message {
100	unsigned int mrq;
101
102	struct {
103		const void *data;
104		size_t size;
105	} tx;
106
107	struct {
108		void *data;
109		size_t size;
 
110	} rx;
 
 
111};
112
 
 
 
113int tegra_bpmp_transfer_atomic(struct tegra_bpmp *bpmp,
114			       struct tegra_bpmp_message *msg);
115int tegra_bpmp_transfer(struct tegra_bpmp *bpmp,
116			struct tegra_bpmp_message *msg);
 
 
117
118int tegra_bpmp_request_mrq(struct tegra_bpmp *bpmp, unsigned int mrq,
119			   tegra_bpmp_mrq_handler_t handler, void *data);
120void tegra_bpmp_free_mrq(struct tegra_bpmp *bpmp, unsigned int mrq,
121			 void *data);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
123#if IS_ENABLED(CONFIG_CLK_TEGRA_BPMP)
124int tegra_bpmp_init_clocks(struct tegra_bpmp *bpmp);
125#else
126static inline int tegra_bpmp_init_clocks(struct tegra_bpmp *bpmp)
127{
128	return 0;
129}
130#endif
131
132#if IS_ENABLED(CONFIG_RESET_TEGRA_BPMP)
133int tegra_bpmp_init_resets(struct tegra_bpmp *bpmp);
134#else
135static inline int tegra_bpmp_init_resets(struct tegra_bpmp *bpmp)
136{
137	return 0;
138}
139#endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
141#endif /* __SOC_TEGRA_BPMP_H */
v6.8
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2/*
  3 * Copyright (c) 2016, NVIDIA CORPORATION.  All rights reserved.
 
 
 
 
 
 
 
 
 
  4 */
  5
  6#ifndef __SOC_TEGRA_BPMP_H
  7#define __SOC_TEGRA_BPMP_H
  8
  9#include <linux/iosys-map.h>
 10#include <linux/mailbox_client.h>
 11#include <linux/pm_domain.h>
 12#include <linux/reset-controller.h>
 13#include <linux/semaphore.h>
 14#include <linux/types.h>
 15
 16#include <soc/tegra/bpmp-abi.h>
 17
 18struct tegra_bpmp_clk;
 19struct tegra_bpmp_ops;
 20
 21struct tegra_bpmp_soc {
 22	struct {
 23		struct {
 24			unsigned int offset;
 25			unsigned int count;
 26			unsigned int timeout;
 27		} cpu_tx, thread, cpu_rx;
 28	} channels;
 29
 30	const struct tegra_bpmp_ops *ops;
 31	unsigned int num_resets;
 32};
 33
 34struct tegra_bpmp_mb_data {
 35	u32 code;
 36	u32 flags;
 37	u8 data[MSG_DATA_MIN_SZ];
 38} __packed;
 39
 40#define tegra_bpmp_mb_read(dst, mb, size) \
 41	iosys_map_memcpy_from(dst, mb, offsetof(struct tegra_bpmp_mb_data, data), size)
 42
 43#define tegra_bpmp_mb_write(mb, src, size) \
 44	iosys_map_memcpy_to(mb, offsetof(struct tegra_bpmp_mb_data, data), src, size)
 45
 46#define tegra_bpmp_mb_read_field(mb, field) \
 47	iosys_map_rd_field(mb, 0, struct tegra_bpmp_mb_data, field)
 48
 49#define tegra_bpmp_mb_write_field(mb, field, value) \
 50	iosys_map_wr_field(mb, 0, struct tegra_bpmp_mb_data, field, value)
 51
 52struct tegra_bpmp_channel {
 53	struct tegra_bpmp *bpmp;
 54	struct iosys_map ib;
 55	struct iosys_map ob;
 56	struct completion completion;
 57	struct tegra_ivc *ivc;
 58	unsigned int index;
 59};
 60
 61typedef void (*tegra_bpmp_mrq_handler_t)(unsigned int mrq,
 62					 struct tegra_bpmp_channel *channel,
 63					 void *data);
 64
 65struct tegra_bpmp_mrq {
 66	struct list_head list;
 67	unsigned int mrq;
 68	tegra_bpmp_mrq_handler_t handler;
 69	void *data;
 70};
 71
 72struct tegra_bpmp {
 73	const struct tegra_bpmp_soc *soc;
 74	struct device *dev;
 75	void *priv;
 
 
 
 
 
 76
 77	struct {
 78		struct mbox_client client;
 79		struct mbox_chan *channel;
 80	} mbox;
 81
 82	spinlock_t atomic_tx_lock;
 83	struct tegra_bpmp_channel *tx_channel, *rx_channel, *threaded_channels;
 84
 85	struct {
 86		unsigned long *allocated;
 87		unsigned long *busy;
 88		unsigned int count;
 89		struct semaphore lock;
 90	} threaded;
 91
 92	struct list_head mrqs;
 93	spinlock_t lock;
 94
 95	struct tegra_bpmp_clk **clocks;
 96	unsigned int num_clocks;
 97
 98	struct reset_controller_dev rstc;
 99
100	struct genpd_onecell_data genpd;
101
102#ifdef CONFIG_DEBUG_FS
103	struct dentry *debugfs_mirror;
104#endif
105
106	bool suspended;
107};
108
109#define TEGRA_BPMP_MESSAGE_RESET BIT(0)
 
110
111struct tegra_bpmp_message {
112	unsigned int mrq;
113
114	struct {
115		const void *data;
116		size_t size;
117	} tx;
118
119	struct {
120		void *data;
121		size_t size;
122		int ret;
123	} rx;
124
125	unsigned long flags;
126};
127
128#if IS_ENABLED(CONFIG_TEGRA_BPMP)
129struct tegra_bpmp *tegra_bpmp_get(struct device *dev);
130void tegra_bpmp_put(struct tegra_bpmp *bpmp);
131int tegra_bpmp_transfer_atomic(struct tegra_bpmp *bpmp,
132			       struct tegra_bpmp_message *msg);
133int tegra_bpmp_transfer(struct tegra_bpmp *bpmp,
134			struct tegra_bpmp_message *msg);
135void tegra_bpmp_mrq_return(struct tegra_bpmp_channel *channel, int code,
136			   const void *data, size_t size);
137
138int tegra_bpmp_request_mrq(struct tegra_bpmp *bpmp, unsigned int mrq,
139			   tegra_bpmp_mrq_handler_t handler, void *data);
140void tegra_bpmp_free_mrq(struct tegra_bpmp *bpmp, unsigned int mrq,
141			 void *data);
142bool tegra_bpmp_mrq_is_supported(struct tegra_bpmp *bpmp, unsigned int mrq);
143#else
144static inline struct tegra_bpmp *tegra_bpmp_get(struct device *dev)
145{
146	return ERR_PTR(-ENOTSUPP);
147}
148static inline void tegra_bpmp_put(struct tegra_bpmp *bpmp)
149{
150}
151static inline int tegra_bpmp_transfer_atomic(struct tegra_bpmp *bpmp,
152					     struct tegra_bpmp_message *msg)
153{
154	return -ENOTSUPP;
155}
156static inline int tegra_bpmp_transfer(struct tegra_bpmp *bpmp,
157				      struct tegra_bpmp_message *msg)
158{
159	return -ENOTSUPP;
160}
161static inline void tegra_bpmp_mrq_return(struct tegra_bpmp_channel *channel,
162					 int code, const void *data,
163					 size_t size)
164{
165}
166
167static inline int tegra_bpmp_request_mrq(struct tegra_bpmp *bpmp,
168					 unsigned int mrq,
169					 tegra_bpmp_mrq_handler_t handler,
170					 void *data)
171{
172	return -ENOTSUPP;
173}
174static inline void tegra_bpmp_free_mrq(struct tegra_bpmp *bpmp,
175				       unsigned int mrq, void *data)
176{
177}
178
179static inline bool tegra_bpmp_mrq_is_supported(struct tegra_bpmp *bpmp,
180					      unsigned int mrq)
181{
182	return false;
183}
184#endif
185
186void tegra_bpmp_handle_rx(struct tegra_bpmp *bpmp);
187
188#if IS_ENABLED(CONFIG_CLK_TEGRA_BPMP)
189int tegra_bpmp_init_clocks(struct tegra_bpmp *bpmp);
190#else
191static inline int tegra_bpmp_init_clocks(struct tegra_bpmp *bpmp)
192{
193	return 0;
194}
195#endif
196
197#if IS_ENABLED(CONFIG_RESET_TEGRA_BPMP)
198int tegra_bpmp_init_resets(struct tegra_bpmp *bpmp);
199#else
200static inline int tegra_bpmp_init_resets(struct tegra_bpmp *bpmp)
201{
202	return 0;
203}
204#endif
205
206#if IS_ENABLED(CONFIG_SOC_TEGRA_POWERGATE_BPMP)
207int tegra_bpmp_init_powergates(struct tegra_bpmp *bpmp);
208#else
209static inline int tegra_bpmp_init_powergates(struct tegra_bpmp *bpmp)
210{
211	return 0;
212}
213#endif
214
215#if IS_ENABLED(CONFIG_DEBUG_FS)
216int tegra_bpmp_init_debugfs(struct tegra_bpmp *bpmp);
217#else
218static inline int tegra_bpmp_init_debugfs(struct tegra_bpmp *bpmp)
219{
220	return 0;
221}
222#endif
223
224
225#endif /* __SOC_TEGRA_BPMP_H */