]> asedeno.scripts.mit.edu Git - linux.git/blob - include/soc/tegra/bpmp.h
Merge tag 'gvt-fixes-2017-05-11' of https://github.com/01org/gvt-linux into drm-intel...
[linux.git] / include / soc / tegra / bpmp.h
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
24 struct tegra_bpmp_clk;
25
26 struct 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
37 struct tegra_bpmp_mb_data {
38         u32 code;
39         u32 flags;
40         u8 data[MSG_DATA_MIN_SZ];
41 } __packed;
42
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;
49 };
50
51 typedef void (*tegra_bpmp_mrq_handler_t)(unsigned int mrq,
52                                          struct tegra_bpmp_channel *channel,
53                                          void *data);
54
55 struct tegra_bpmp_mrq {
56         struct list_head list;
57         unsigned int mrq;
58         tegra_bpmp_mrq_handler_t handler;
59         void *data;
60 };
61
62 struct 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
96 struct tegra_bpmp *tegra_bpmp_get(struct device *dev);
97 void tegra_bpmp_put(struct tegra_bpmp *bpmp);
98
99 struct 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
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);
117
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,
121                          void *data);
122
123 #if IS_ENABLED(CONFIG_CLK_TEGRA_BPMP)
124 int tegra_bpmp_init_clocks(struct tegra_bpmp *bpmp);
125 #else
126 static 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)
133 int tegra_bpmp_init_resets(struct tegra_bpmp *bpmp);
134 #else
135 static inline int tegra_bpmp_init_resets(struct tegra_bpmp *bpmp)
136 {
137         return 0;
138 }
139 #endif
140
141 #endif /* __SOC_TEGRA_BPMP_H */