Home | History | Annotate | Line # | Download | only in irq
      1 /*	$NetBSD: irq_service.h,v 1.2 2021/12/18 23:45:06 riastradh Exp $	*/
      2 
      3 /*
      4  * Copyright 2012-15 Advanced Micro Devices, Inc.
      5  *
      6  * Permission is hereby granted, free of charge, to any person obtaining a
      7  * copy of this software and associated documentation files (the "Software"),
      8  * to deal in the Software without restriction, including without limitation
      9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     10  * and/or sell copies of the Software, and to permit persons to whom the
     11  * Software is furnished to do so, subject to the following conditions:
     12  *
     13  * The above copyright notice and this permission notice shall be included in
     14  * all copies or substantial portions of the Software.
     15  *
     16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     19  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
     20  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     22  * OTHER DEALINGS IN THE SOFTWARE.
     23  *
     24  * Authors: AMD
     25  *
     26  */
     27 
     28 #ifndef __DAL_IRQ_SERVICE_H__
     29 #define __DAL_IRQ_SERVICE_H__
     30 
     31 #include "include/irq_service_interface.h"
     32 
     33 #include "irq_types.h"
     34 
     35 struct irq_service;
     36 struct irq_source_info;
     37 
     38 struct irq_source_info_funcs {
     39 	bool (*set)(
     40 		struct irq_service *irq_service,
     41 		const struct irq_source_info *info,
     42 		bool enable);
     43 	bool (*ack)(
     44 		struct irq_service *irq_service,
     45 		const struct irq_source_info *info);
     46 };
     47 
     48 struct irq_source_info {
     49 	uint32_t src_id;
     50 	uint32_t ext_id;
     51 	uint32_t enable_reg;
     52 	uint32_t enable_mask;
     53 	uint32_t enable_value[2];
     54 	uint32_t ack_reg;
     55 	uint32_t ack_mask;
     56 	uint32_t ack_value;
     57 	uint32_t status_reg;
     58 	const struct irq_source_info_funcs *funcs;
     59 };
     60 
     61 struct irq_service_funcs {
     62 	enum dc_irq_source (*to_dal_irq_source)(
     63 			struct irq_service *irq_service,
     64 			uint32_t src_id,
     65 			uint32_t ext_id);
     66 };
     67 
     68 struct irq_service {
     69 	struct dc_context *ctx;
     70 	const struct irq_source_info *info;
     71 	const struct irq_service_funcs *funcs;
     72 };
     73 
     74 void dal_irq_service_construct(
     75 	struct irq_service *irq_service,
     76 	struct irq_service_init_data *init_data);
     77 
     78 void dal_irq_service_ack_generic(
     79 	struct irq_service *irq_service,
     80 	const struct irq_source_info *info);
     81 
     82 void dal_irq_service_set_generic(
     83 	struct irq_service *irq_service,
     84 	const struct irq_source_info *info,
     85 	bool enable);
     86 
     87 #endif
     88