Home | History | Annotate | Line # | Download | only in hw
      1 /*	$NetBSD: gpio.h,v 1.2 2021/12/18 23:45:05 riastradh Exp $	*/
      2 
      3 /*
      4  * Copyright 2012-16 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_GPIO_H__
     29 #define __DAL_GPIO_H__
     30 
     31 #include "gpio_types.h"
     32 
     33 
     34 union gpio_hw_container {
     35 	struct hw_ddc *ddc;
     36 	struct hw_generic *generic;
     37 	struct hw_hpd *hpd;
     38 };
     39 
     40 struct gpio {
     41 	struct gpio_service *service;
     42 	struct hw_gpio_pin *pin;
     43 	enum gpio_id id;
     44 	uint32_t en;
     45 
     46 	union gpio_hw_container hw_container;
     47 	enum gpio_mode mode;
     48 
     49 	/* when GPIO comes from VBIOS, it has defined output state */
     50 	enum gpio_pin_output_state output_state;
     51 };
     52 
     53 #if 0
     54 struct gpio_funcs {
     55 
     56 	struct hw_gpio_pin *(*create_ddc_data)(
     57 		struct dc_context *ctx,
     58 		enum gpio_id id,
     59 		uint32_t en);
     60 	struct hw_gpio_pin *(*create_ddc_clock)(
     61 		struct dc_context *ctx,
     62 		enum gpio_id id,
     63 		uint32_t en);
     64 	struct hw_gpio_pin *(*create_generic)(
     65 		struct dc_context *ctx,
     66 		enum gpio_id id,
     67 		uint32_t en);
     68 	struct hw_gpio_pin *(*create_hpd)(
     69 		struct dc_context *ctx,
     70 		enum gpio_id id,
     71 		uint32_t en);
     72 	struct hw_gpio_pin *(*create_gpio_pad)(
     73 		struct dc_context *ctx,
     74 		enum gpio_id id,
     75 		uint32_t en);
     76 	struct hw_gpio_pin *(*create_sync)(
     77 		struct dc_context *ctx,
     78 		enum gpio_id id,
     79 		uint32_t en);
     80 	struct hw_gpio_pin *(*create_gsl)(
     81 		struct dc_context *ctx,
     82 		enum gpio_id id,
     83 		uint32_t en);
     84 
     85 	/* HW translation */
     86 	bool (*offset_to_id)(
     87 		uint32_t offset,
     88 		uint32_t mask,
     89 		enum gpio_id *id,
     90 		uint32_t *en);
     91 	bool (*id_to_offset)(
     92 		enum gpio_id id,
     93 		uint32_t en,
     94 		struct gpio_pin_info *info);
     95 };
     96 #endif
     97 
     98 #endif  /* __DAL_GPIO__ */
     99