]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/soc/tegra/bpmp.h
Merge git://www.linux-watchdog.org/linux-watchdog
[mirror_ubuntu-bionic-kernel.git] / include / soc / tegra / bpmp.h
CommitLineData
983de5f9
TR
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>
e7149a7a 18#include <linux/pm_domain.h>
983de5f9
TR
19#include <linux/reset-controller.h>
20#include <linux/semaphore.h>
21#include <linux/types.h>
22
23#include <soc/tegra/bpmp-abi.h>
24
25struct tegra_bpmp_clk;
26
27struct tegra_bpmp_soc {
28 struct {
29 struct {
30 unsigned int offset;
31 unsigned int count;
32 unsigned int timeout;
33 } cpu_tx, thread, cpu_rx;
34 } channels;
35 unsigned int num_resets;
36};
37
38struct tegra_bpmp_mb_data {
39 u32 code;
40 u32 flags;
41 u8 data[MSG_DATA_MIN_SZ];
42} __packed;
43
44struct tegra_bpmp_channel {
45 struct tegra_bpmp *bpmp;
46 struct tegra_bpmp_mb_data *ib;
47 struct tegra_bpmp_mb_data *ob;
48 struct completion completion;
49 struct tegra_ivc *ivc;
50};
51
52typedef void (*tegra_bpmp_mrq_handler_t)(unsigned int mrq,
53 struct tegra_bpmp_channel *channel,
54 void *data);
55
56struct tegra_bpmp_mrq {
57 struct list_head list;
58 unsigned int mrq;
59 tegra_bpmp_mrq_handler_t handler;
60 void *data;
61};
62
63struct tegra_bpmp {
64 const struct tegra_bpmp_soc *soc;
65 struct device *dev;
66
67 struct {
68 struct gen_pool *pool;
69 dma_addr_t phys;
70 void *virt;
71 } tx, rx;
72
73 struct {
74 struct mbox_client client;
75 struct mbox_chan *channel;
76 } mbox;
77
78 struct tegra_bpmp_channel *channels;
79 unsigned int num_channels;
80
81 struct {
82 unsigned long *allocated;
83 unsigned long *busy;
84 unsigned int count;
85 struct semaphore lock;
86 } threaded;
87
88 struct list_head mrqs;
89 spinlock_t lock;
90
91 struct tegra_bpmp_clk **clocks;
92 unsigned int num_clocks;
93
94 struct reset_controller_dev rstc;
e7149a7a
TR
95
96 struct genpd_onecell_data genpd;
983de5f9
TR
97};
98
99struct tegra_bpmp *tegra_bpmp_get(struct device *dev);
100void tegra_bpmp_put(struct tegra_bpmp *bpmp);
101
102struct tegra_bpmp_message {
103 unsigned int mrq;
104
105 struct {
106 const void *data;
107 size_t size;
108 } tx;
109
110 struct {
111 void *data;
112 size_t size;
113 } rx;
114};
115
116int tegra_bpmp_transfer_atomic(struct tegra_bpmp *bpmp,
117 struct tegra_bpmp_message *msg);
118int tegra_bpmp_transfer(struct tegra_bpmp *bpmp,
119 struct tegra_bpmp_message *msg);
120
121int tegra_bpmp_request_mrq(struct tegra_bpmp *bpmp, unsigned int mrq,
122 tegra_bpmp_mrq_handler_t handler, void *data);
123void tegra_bpmp_free_mrq(struct tegra_bpmp *bpmp, unsigned int mrq,
124 void *data);
125
126#if IS_ENABLED(CONFIG_CLK_TEGRA_BPMP)
127int tegra_bpmp_init_clocks(struct tegra_bpmp *bpmp);
128#else
129static inline int tegra_bpmp_init_clocks(struct tegra_bpmp *bpmp)
130{
131 return 0;
132}
133#endif
134
135#if IS_ENABLED(CONFIG_RESET_TEGRA_BPMP)
136int tegra_bpmp_init_resets(struct tegra_bpmp *bpmp);
137#else
138static inline int tegra_bpmp_init_resets(struct tegra_bpmp *bpmp)
139{
140 return 0;
141}
142#endif
143
e7149a7a
TR
144#if IS_ENABLED(CONFIG_SOC_TEGRA_POWERGATE_BPMP)
145int tegra_bpmp_init_powergates(struct tegra_bpmp *bpmp);
146#else
147static inline int tegra_bpmp_init_powergates(struct tegra_bpmp *bpmp)
148{
149 return 0;
150}
151#endif
152
983de5f9 153#endif /* __SOC_TEGRA_BPMP_H */