14562236bSHarry Wentland /*
24562236bSHarry Wentland  * Copyright 2012-15 Advanced Micro Devices, Inc.
34562236bSHarry Wentland  *
44562236bSHarry Wentland  * Permission is hereby granted, free of charge, to any person obtaining a
54562236bSHarry Wentland  * copy of this software and associated documentation files (the "Software"),
64562236bSHarry Wentland  * to deal in the Software without restriction, including without limitation
74562236bSHarry Wentland  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
84562236bSHarry Wentland  * and/or sell copies of the Software, and to permit persons to whom the
94562236bSHarry Wentland  * Software is furnished to do so, subject to the following conditions:
104562236bSHarry Wentland  *
114562236bSHarry Wentland  * The above copyright notice and this permission notice shall be included in
124562236bSHarry Wentland  * all copies or substantial portions of the Software.
134562236bSHarry Wentland  *
144562236bSHarry Wentland  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
154562236bSHarry Wentland  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
164562236bSHarry Wentland  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
174562236bSHarry Wentland  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
184562236bSHarry Wentland  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
194562236bSHarry Wentland  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
204562236bSHarry Wentland  * OTHER DEALINGS IN THE SOFTWARE.
214562236bSHarry Wentland  *
224562236bSHarry Wentland  * Authors: AMD
234562236bSHarry Wentland  *
244562236bSHarry Wentland  */
254562236bSHarry Wentland 
264562236bSHarry Wentland #ifndef __DAL_IRQ_SERVICE_H__
274562236bSHarry Wentland #define __DAL_IRQ_SERVICE_H__
284562236bSHarry Wentland 
294562236bSHarry Wentland #include "include/irq_service_interface.h"
304562236bSHarry Wentland 
314562236bSHarry Wentland #include "irq_types.h"
324562236bSHarry Wentland 
334562236bSHarry Wentland struct irq_service;
344562236bSHarry Wentland struct irq_source_info;
354562236bSHarry Wentland 
364562236bSHarry Wentland struct irq_source_info_funcs {
374562236bSHarry Wentland 	bool (*set)(
384562236bSHarry Wentland 		struct irq_service *irq_service,
394562236bSHarry Wentland 		const struct irq_source_info *info,
404562236bSHarry Wentland 		bool enable);
414562236bSHarry Wentland 	bool (*ack)(
424562236bSHarry Wentland 		struct irq_service *irq_service,
434562236bSHarry Wentland 		const struct irq_source_info *info);
444562236bSHarry Wentland };
454562236bSHarry Wentland 
464562236bSHarry Wentland struct irq_source_info {
474562236bSHarry Wentland 	uint32_t src_id;
484562236bSHarry Wentland 	uint32_t ext_id;
494562236bSHarry Wentland 	uint32_t enable_reg;
504562236bSHarry Wentland 	uint32_t enable_mask;
514562236bSHarry Wentland 	uint32_t enable_value[2];
524562236bSHarry Wentland 	uint32_t ack_reg;
534562236bSHarry Wentland 	uint32_t ack_mask;
544562236bSHarry Wentland 	uint32_t ack_value;
554562236bSHarry Wentland 	uint32_t status_reg;
564562236bSHarry Wentland 	const struct irq_source_info_funcs *funcs;
574562236bSHarry Wentland };
584562236bSHarry Wentland 
594562236bSHarry Wentland struct irq_service_funcs {
604562236bSHarry Wentland 	enum dc_irq_source (*to_dal_irq_source)(
614562236bSHarry Wentland 			struct irq_service *irq_service,
624562236bSHarry Wentland 			uint32_t src_id,
634562236bSHarry Wentland 			uint32_t ext_id);
644562236bSHarry Wentland };
654562236bSHarry Wentland 
664562236bSHarry Wentland struct irq_service {
674562236bSHarry Wentland 	struct dc_context *ctx;
684562236bSHarry Wentland 	const struct irq_source_info *info;
694562236bSHarry Wentland 	const struct irq_service_funcs *funcs;
704562236bSHarry Wentland };
714562236bSHarry Wentland 
726be663b5SDave Airlie void dal_irq_service_construct(
734562236bSHarry Wentland 	struct irq_service *irq_service,
744562236bSHarry Wentland 	struct irq_service_init_data *init_data);
754562236bSHarry Wentland 
764562236bSHarry Wentland void dal_irq_service_ack_generic(
774562236bSHarry Wentland 	struct irq_service *irq_service,
784562236bSHarry Wentland 	const struct irq_source_info *info);
794562236bSHarry Wentland 
804562236bSHarry Wentland void dal_irq_service_set_generic(
814562236bSHarry Wentland 	struct irq_service *irq_service,
824562236bSHarry Wentland 	const struct irq_source_info *info,
834562236bSHarry Wentland 	bool enable);
844562236bSHarry Wentland 
854562236bSHarry Wentland #endif
86