xref: /openbmc/linux/arch/powerpc/include/asm/spu_priv1.h (revision 75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37)
1*873e65bcSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2b8b572e1SStephen Rothwell /*
3b8b572e1SStephen Rothwell  * Defines an spu hypervisor abstraction layer.
4b8b572e1SStephen Rothwell  *
5b8b572e1SStephen Rothwell  *  Copyright 2006 Sony Corp.
6b8b572e1SStephen Rothwell  */
7b8b572e1SStephen Rothwell 
8b8b572e1SStephen Rothwell #if !defined(_SPU_PRIV1_H)
9b8b572e1SStephen Rothwell #define _SPU_PRIV1_H
10b8b572e1SStephen Rothwell #if defined(__KERNEL__)
11b8b572e1SStephen Rothwell 
12b8b572e1SStephen Rothwell #include <linux/types.h>
13b8b572e1SStephen Rothwell 
14b8b572e1SStephen Rothwell struct spu;
15b8b572e1SStephen Rothwell struct spu_context;
16b8b572e1SStephen Rothwell 
17b8b572e1SStephen Rothwell /* access to priv1 registers */
18b8b572e1SStephen Rothwell 
19b8b572e1SStephen Rothwell struct spu_priv1_ops {
20b8b572e1SStephen Rothwell 	void (*int_mask_and) (struct spu *spu, int class, u64 mask);
21b8b572e1SStephen Rothwell 	void (*int_mask_or) (struct spu *spu, int class, u64 mask);
22b8b572e1SStephen Rothwell 	void (*int_mask_set) (struct spu *spu, int class, u64 mask);
23b8b572e1SStephen Rothwell 	u64 (*int_mask_get) (struct spu *spu, int class);
24b8b572e1SStephen Rothwell 	void (*int_stat_clear) (struct spu *spu, int class, u64 stat);
25b8b572e1SStephen Rothwell 	u64 (*int_stat_get) (struct spu *spu, int class);
26b8b572e1SStephen Rothwell 	void (*cpu_affinity_set) (struct spu *spu, int cpu);
27b8b572e1SStephen Rothwell 	u64 (*mfc_dar_get) (struct spu *spu);
28b8b572e1SStephen Rothwell 	u64 (*mfc_dsisr_get) (struct spu *spu);
29b8b572e1SStephen Rothwell 	void (*mfc_dsisr_set) (struct spu *spu, u64 dsisr);
30b8b572e1SStephen Rothwell 	void (*mfc_sdr_setup) (struct spu *spu);
31b8b572e1SStephen Rothwell 	void (*mfc_sr1_set) (struct spu *spu, u64 sr1);
32b8b572e1SStephen Rothwell 	u64 (*mfc_sr1_get) (struct spu *spu);
33b8b572e1SStephen Rothwell 	void (*mfc_tclass_id_set) (struct spu *spu, u64 tclass_id);
34b8b572e1SStephen Rothwell 	u64 (*mfc_tclass_id_get) (struct spu *spu);
35b8b572e1SStephen Rothwell 	void (*tlb_invalidate) (struct spu *spu);
36b8b572e1SStephen Rothwell 	void (*resource_allocation_groupID_set) (struct spu *spu, u64 id);
37b8b572e1SStephen Rothwell 	u64 (*resource_allocation_groupID_get) (struct spu *spu);
38b8b572e1SStephen Rothwell 	void (*resource_allocation_enable_set) (struct spu *spu, u64 enable);
39b8b572e1SStephen Rothwell 	u64 (*resource_allocation_enable_get) (struct spu *spu);
40b8b572e1SStephen Rothwell };
41b8b572e1SStephen Rothwell 
42b8b572e1SStephen Rothwell extern const struct spu_priv1_ops* spu_priv1_ops;
43b8b572e1SStephen Rothwell 
44b8b572e1SStephen Rothwell static inline void
spu_int_mask_and(struct spu * spu,int class,u64 mask)45b8b572e1SStephen Rothwell spu_int_mask_and (struct spu *spu, int class, u64 mask)
46b8b572e1SStephen Rothwell {
47b8b572e1SStephen Rothwell 	spu_priv1_ops->int_mask_and(spu, class, mask);
48b8b572e1SStephen Rothwell }
49b8b572e1SStephen Rothwell 
50b8b572e1SStephen Rothwell static inline void
spu_int_mask_or(struct spu * spu,int class,u64 mask)51b8b572e1SStephen Rothwell spu_int_mask_or (struct spu *spu, int class, u64 mask)
52b8b572e1SStephen Rothwell {
53b8b572e1SStephen Rothwell 	spu_priv1_ops->int_mask_or(spu, class, mask);
54b8b572e1SStephen Rothwell }
55b8b572e1SStephen Rothwell 
56b8b572e1SStephen Rothwell static inline void
spu_int_mask_set(struct spu * spu,int class,u64 mask)57b8b572e1SStephen Rothwell spu_int_mask_set (struct spu *spu, int class, u64 mask)
58b8b572e1SStephen Rothwell {
59b8b572e1SStephen Rothwell 	spu_priv1_ops->int_mask_set(spu, class, mask);
60b8b572e1SStephen Rothwell }
61b8b572e1SStephen Rothwell 
62b8b572e1SStephen Rothwell static inline u64
spu_int_mask_get(struct spu * spu,int class)63b8b572e1SStephen Rothwell spu_int_mask_get (struct spu *spu, int class)
64b8b572e1SStephen Rothwell {
65b8b572e1SStephen Rothwell 	return spu_priv1_ops->int_mask_get(spu, class);
66b8b572e1SStephen Rothwell }
67b8b572e1SStephen Rothwell 
68b8b572e1SStephen Rothwell static inline void
spu_int_stat_clear(struct spu * spu,int class,u64 stat)69b8b572e1SStephen Rothwell spu_int_stat_clear (struct spu *spu, int class, u64 stat)
70b8b572e1SStephen Rothwell {
71b8b572e1SStephen Rothwell 	spu_priv1_ops->int_stat_clear(spu, class, stat);
72b8b572e1SStephen Rothwell }
73b8b572e1SStephen Rothwell 
74b8b572e1SStephen Rothwell static inline u64
spu_int_stat_get(struct spu * spu,int class)75b8b572e1SStephen Rothwell spu_int_stat_get (struct spu *spu, int class)
76b8b572e1SStephen Rothwell {
77b8b572e1SStephen Rothwell 	return spu_priv1_ops->int_stat_get (spu, class);
78b8b572e1SStephen Rothwell }
79b8b572e1SStephen Rothwell 
80b8b572e1SStephen Rothwell static inline void
spu_cpu_affinity_set(struct spu * spu,int cpu)81b8b572e1SStephen Rothwell spu_cpu_affinity_set (struct spu *spu, int cpu)
82b8b572e1SStephen Rothwell {
83b8b572e1SStephen Rothwell 	spu_priv1_ops->cpu_affinity_set(spu, cpu);
84b8b572e1SStephen Rothwell }
85b8b572e1SStephen Rothwell 
86b8b572e1SStephen Rothwell static inline u64
spu_mfc_dar_get(struct spu * spu)87b8b572e1SStephen Rothwell spu_mfc_dar_get (struct spu *spu)
88b8b572e1SStephen Rothwell {
89b8b572e1SStephen Rothwell 	return spu_priv1_ops->mfc_dar_get(spu);
90b8b572e1SStephen Rothwell }
91b8b572e1SStephen Rothwell 
92b8b572e1SStephen Rothwell static inline u64
spu_mfc_dsisr_get(struct spu * spu)93b8b572e1SStephen Rothwell spu_mfc_dsisr_get (struct spu *spu)
94b8b572e1SStephen Rothwell {
95b8b572e1SStephen Rothwell 	return spu_priv1_ops->mfc_dsisr_get(spu);
96b8b572e1SStephen Rothwell }
97b8b572e1SStephen Rothwell 
98b8b572e1SStephen Rothwell static inline void
spu_mfc_dsisr_set(struct spu * spu,u64 dsisr)99b8b572e1SStephen Rothwell spu_mfc_dsisr_set (struct spu *spu, u64 dsisr)
100b8b572e1SStephen Rothwell {
101b8b572e1SStephen Rothwell 	spu_priv1_ops->mfc_dsisr_set(spu, dsisr);
102b8b572e1SStephen Rothwell }
103b8b572e1SStephen Rothwell 
104b8b572e1SStephen Rothwell static inline void
spu_mfc_sdr_setup(struct spu * spu)105b8b572e1SStephen Rothwell spu_mfc_sdr_setup (struct spu *spu)
106b8b572e1SStephen Rothwell {
107b8b572e1SStephen Rothwell 	spu_priv1_ops->mfc_sdr_setup(spu);
108b8b572e1SStephen Rothwell }
109b8b572e1SStephen Rothwell 
110b8b572e1SStephen Rothwell static inline void
spu_mfc_sr1_set(struct spu * spu,u64 sr1)111b8b572e1SStephen Rothwell spu_mfc_sr1_set (struct spu *spu, u64 sr1)
112b8b572e1SStephen Rothwell {
113b8b572e1SStephen Rothwell 	spu_priv1_ops->mfc_sr1_set(spu, sr1);
114b8b572e1SStephen Rothwell }
115b8b572e1SStephen Rothwell 
116b8b572e1SStephen Rothwell static inline u64
spu_mfc_sr1_get(struct spu * spu)117b8b572e1SStephen Rothwell spu_mfc_sr1_get (struct spu *spu)
118b8b572e1SStephen Rothwell {
119b8b572e1SStephen Rothwell 	return spu_priv1_ops->mfc_sr1_get(spu);
120b8b572e1SStephen Rothwell }
121b8b572e1SStephen Rothwell 
122b8b572e1SStephen Rothwell static inline void
spu_mfc_tclass_id_set(struct spu * spu,u64 tclass_id)123b8b572e1SStephen Rothwell spu_mfc_tclass_id_set (struct spu *spu, u64 tclass_id)
124b8b572e1SStephen Rothwell {
125b8b572e1SStephen Rothwell 	spu_priv1_ops->mfc_tclass_id_set(spu, tclass_id);
126b8b572e1SStephen Rothwell }
127b8b572e1SStephen Rothwell 
128b8b572e1SStephen Rothwell static inline u64
spu_mfc_tclass_id_get(struct spu * spu)129b8b572e1SStephen Rothwell spu_mfc_tclass_id_get (struct spu *spu)
130b8b572e1SStephen Rothwell {
131b8b572e1SStephen Rothwell 	return spu_priv1_ops->mfc_tclass_id_get(spu);
132b8b572e1SStephen Rothwell }
133b8b572e1SStephen Rothwell 
134b8b572e1SStephen Rothwell static inline void
spu_tlb_invalidate(struct spu * spu)135b8b572e1SStephen Rothwell spu_tlb_invalidate (struct spu *spu)
136b8b572e1SStephen Rothwell {
137b8b572e1SStephen Rothwell 	spu_priv1_ops->tlb_invalidate(spu);
138b8b572e1SStephen Rothwell }
139b8b572e1SStephen Rothwell 
140b8b572e1SStephen Rothwell static inline void
spu_resource_allocation_groupID_set(struct spu * spu,u64 id)141b8b572e1SStephen Rothwell spu_resource_allocation_groupID_set (struct spu *spu, u64 id)
142b8b572e1SStephen Rothwell {
143b8b572e1SStephen Rothwell 	spu_priv1_ops->resource_allocation_groupID_set(spu, id);
144b8b572e1SStephen Rothwell }
145b8b572e1SStephen Rothwell 
146b8b572e1SStephen Rothwell static inline u64
spu_resource_allocation_groupID_get(struct spu * spu)147b8b572e1SStephen Rothwell spu_resource_allocation_groupID_get (struct spu *spu)
148b8b572e1SStephen Rothwell {
149b8b572e1SStephen Rothwell 	return spu_priv1_ops->resource_allocation_groupID_get(spu);
150b8b572e1SStephen Rothwell }
151b8b572e1SStephen Rothwell 
152b8b572e1SStephen Rothwell static inline void
spu_resource_allocation_enable_set(struct spu * spu,u64 enable)153b8b572e1SStephen Rothwell spu_resource_allocation_enable_set (struct spu *spu, u64 enable)
154b8b572e1SStephen Rothwell {
155b8b572e1SStephen Rothwell 	spu_priv1_ops->resource_allocation_enable_set(spu, enable);
156b8b572e1SStephen Rothwell }
157b8b572e1SStephen Rothwell 
158b8b572e1SStephen Rothwell static inline u64
spu_resource_allocation_enable_get(struct spu * spu)159b8b572e1SStephen Rothwell spu_resource_allocation_enable_get (struct spu *spu)
160b8b572e1SStephen Rothwell {
161b8b572e1SStephen Rothwell 	return spu_priv1_ops->resource_allocation_enable_get(spu);
162b8b572e1SStephen Rothwell }
163b8b572e1SStephen Rothwell 
164b8b572e1SStephen Rothwell /* spu management abstraction */
165b8b572e1SStephen Rothwell 
166b8b572e1SStephen Rothwell struct spu_management_ops {
167b8b572e1SStephen Rothwell 	int (*enumerate_spus)(int (*fn)(void *data));
168b8b572e1SStephen Rothwell 	int (*create_spu)(struct spu *spu, void *data);
169b8b572e1SStephen Rothwell 	int (*destroy_spu)(struct spu *spu);
170b8b572e1SStephen Rothwell 	void (*enable_spu)(struct spu_context *ctx);
171b8b572e1SStephen Rothwell 	void (*disable_spu)(struct spu_context *ctx);
172b8b572e1SStephen Rothwell 	int (*init_affinity)(void);
173b8b572e1SStephen Rothwell };
174b8b572e1SStephen Rothwell 
175b8b572e1SStephen Rothwell extern const struct spu_management_ops* spu_management_ops;
176b8b572e1SStephen Rothwell 
177b8b572e1SStephen Rothwell static inline int
spu_enumerate_spus(int (* fn)(void * data))178b8b572e1SStephen Rothwell spu_enumerate_spus (int (*fn)(void *data))
179b8b572e1SStephen Rothwell {
180b8b572e1SStephen Rothwell 	return spu_management_ops->enumerate_spus(fn);
181b8b572e1SStephen Rothwell }
182b8b572e1SStephen Rothwell 
183b8b572e1SStephen Rothwell static inline int
spu_create_spu(struct spu * spu,void * data)184b8b572e1SStephen Rothwell spu_create_spu (struct spu *spu, void *data)
185b8b572e1SStephen Rothwell {
186b8b572e1SStephen Rothwell 	return spu_management_ops->create_spu(spu, data);
187b8b572e1SStephen Rothwell }
188b8b572e1SStephen Rothwell 
189b8b572e1SStephen Rothwell static inline int
spu_destroy_spu(struct spu * spu)190b8b572e1SStephen Rothwell spu_destroy_spu (struct spu *spu)
191b8b572e1SStephen Rothwell {
192b8b572e1SStephen Rothwell 	return spu_management_ops->destroy_spu(spu);
193b8b572e1SStephen Rothwell }
194b8b572e1SStephen Rothwell 
195b8b572e1SStephen Rothwell static inline int
spu_init_affinity(void)196b8b572e1SStephen Rothwell spu_init_affinity (void)
197b8b572e1SStephen Rothwell {
198b8b572e1SStephen Rothwell 	return spu_management_ops->init_affinity();
199b8b572e1SStephen Rothwell }
200b8b572e1SStephen Rothwell 
201b8b572e1SStephen Rothwell static inline void
spu_enable_spu(struct spu_context * ctx)202b8b572e1SStephen Rothwell spu_enable_spu (struct spu_context *ctx)
203b8b572e1SStephen Rothwell {
204b8b572e1SStephen Rothwell 	spu_management_ops->enable_spu(ctx);
205b8b572e1SStephen Rothwell }
206b8b572e1SStephen Rothwell 
207b8b572e1SStephen Rothwell static inline void
spu_disable_spu(struct spu_context * ctx)208b8b572e1SStephen Rothwell spu_disable_spu (struct spu_context *ctx)
209b8b572e1SStephen Rothwell {
210b8b572e1SStephen Rothwell 	spu_management_ops->disable_spu(ctx);
211b8b572e1SStephen Rothwell }
212b8b572e1SStephen Rothwell 
213b8b572e1SStephen Rothwell /*
21425985edcSLucas De Marchi  * The declarations following are put here for convenience
215b8b572e1SStephen Rothwell  * and only intended to be used by the platform setup code.
216b8b572e1SStephen Rothwell  */
217b8b572e1SStephen Rothwell 
218b8b572e1SStephen Rothwell extern const struct spu_priv1_ops spu_priv1_mmio_ops;
219b8b572e1SStephen Rothwell extern const struct spu_priv1_ops spu_priv1_beat_ops;
220b8b572e1SStephen Rothwell 
221b8b572e1SStephen Rothwell extern const struct spu_management_ops spu_management_of_ops;
222b8b572e1SStephen Rothwell 
223b8b572e1SStephen Rothwell #endif /* __KERNEL__ */
224b8b572e1SStephen Rothwell #endif
225