Azure Sphere MT3620 M4 API Reference Manual
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
mhal_gpio.h
1 /*
2  * (C) 2005-2020 MediaTek Inc. All rights reserved.
3  *
4  * Copyright Statement:
5  *
6  * This MT3620 driver software/firmware and related documentation
7  * ("MediaTek Software") are protected under relevant copyright laws.
8  * The information contained herein is confidential and proprietary to
9  * MediaTek Inc. ("MediaTek"). You may only use, reproduce, modify, or
10  * distribute (as applicable) MediaTek Software if you have agreed to and been
11  * bound by this Statement and the applicable license agreement with MediaTek
12  * ("License Agreement") and been granted explicit permission to do so within
13  * the License Agreement ("Permitted User"). If you are not a Permitted User,
14  * please cease any access or use of MediaTek Software immediately.
15  *
16  * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
17  * THAT MEDIATEK SOFTWARE RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE
18  * PROVIDED TO RECEIVER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS
19  * ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
21  * NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
22  * RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
23  * INCORPORATED IN, OR SUPPLIED WITH MEDIATEK SOFTWARE, AND RECEIVER AGREES TO
24  * LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
25  * RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
26  * OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
27  * SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
28  * RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
29  * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
30  * ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO MEDIATEK SOFTWARE RELEASED
31  * HEREUNDER WILL BE ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY
32  * RECEIVER TO MEDIATEK DURING THE PRECEDING TWELVE (12) MONTHS FOR SUCH
33  * MEDIATEK SOFTWARE AT ISSUE.
34  */
35 
36 #ifndef __MHAL_GPIO_H__
37 #define __MHAL_GPIO_H__
38 #include "mhal_osai.h"
39 
113 #define EINVAL 1
114 
115 #define EPIN 2
116 
117 #define EINVALFUNC 3
118 
119 #define EFREE 4
120 
121 #define EQUEST 5
122 
123 #define ERROR 6
124 
138 typedef enum {
141  MHAL_GPIO_1 = 1,
142  MHAL_GPIO_2 = 2,
143  MHAL_GPIO_3 = 3,
144  MHAL_GPIO_4 = 4,
145  MHAL_GPIO_5 = 5,
146  MHAL_GPIO_6 = 6,
147  MHAL_GPIO_7 = 7,
148  MHAL_GPIO_8 = 8,
149  MHAL_GPIO_9 = 9,
150  MHAL_GPIO_10 = 10,
151  MHAL_GPIO_11 = 11,
152  MHAL_GPIO_12 = 12,
153  MHAL_GPIO_13 = 13,
154  MHAL_GPIO_14 = 14,
155  MHAL_GPIO_15 = 15,
156  MHAL_GPIO_16 = 16,
157  MHAL_GPIO_17 = 17,
158  MHAL_GPIO_18 = 18,
159  MHAL_GPIO_19 = 19,
160  MHAL_GPIO_20 = 20,
161  MHAL_GPIO_21 = 21,
162  MHAL_GPIO_22 = 22,
163  MHAL_GPIO_23 = 23,
164  MHAL_GPIO_24 = 24,
165  MHAL_GPIO_25 = 25,
166  MHAL_GPIO_26 = 26,
167  MHAL_GPIO_27 = 27,
168  MHAL_GPIO_28 = 28,
169  MHAL_GPIO_29 = 29,
170  MHAL_GPIO_30 = 30,
171  MHAL_GPIO_31 = 31,
172  MHAL_GPIO_32 = 32,
173  MHAL_GPIO_33 = 33,
174  MHAL_GPIO_34 = 34,
175  MHAL_GPIO_35 = 35,
176  MHAL_GPIO_36 = 36,
177  MHAL_GPIO_37 = 37,
178  MHAL_GPIO_38 = 38,
179  MHAL_GPIO_39 = 39,
180  MHAL_GPIO_40 = 40,
181  MHAL_GPIO_41 = 41,
182  MHAL_GPIO_42 = 42,
183  MHAL_GPIO_43 = 43,
184  MHAL_GPIO_44 = 44,
185  MHAL_GPIO_45 = 45,
186  MHAL_GPIO_46 = 46,
187  MHAL_GPIO_47 = 47,
188  MHAL_GPIO_48 = 48,
189  MHAL_GPIO_49 = 49,
190  MHAL_GPIO_50 = 50,
191  MHAL_GPIO_51 = 51,
192  MHAL_GPIO_52 = 52,
193  MHAL_GPIO_53 = 53,
194  MHAL_GPIO_54 = 54,
195  MHAL_GPIO_55 = 55,
196  MHAL_GPIO_56 = 56,
197  MHAL_GPIO_57 = 57,
198  MHAL_GPIO_58 = 58,
199  MHAL_GPIO_59 = 59,
200  MHAL_GPIO_60 = 60,
201  MHAL_GPIO_61 = 61,
202  MHAL_GPIO_62 = 62,
203  MHAL_GPIO_63 = 63,
204  MHAL_GPIO_64 = 64,
205  MHAL_GPIO_65 = 65,
206  MHAL_GPIO_66 = 66,
207  MHAL_GPIO_67 = 67,
208  MHAL_GPIO_68 = 68,
209  MHAL_GPIO_69 = 69,
210  MHAL_GPIO_70 = 70,
211  MHAL_GPIO_71 = 71,
212  MHAL_GPIO_72 = 72,
213  MHAL_GPIO_73 = 73,
214  MHAL_GPIO_74 = 74,
215  MHAL_GPIO_75 = 75,
216  MHAL_GPIO_76 = 76,
217  MHAL_GPIO_77 = 77,
218  MHAL_GPIO_78 = 78,
219  MHAL_GPIO_79 = 79,
220  MHAL_GPIO_80 = 80,
221  MHAL_GPIO_81 = 81,
222  MHAL_GPIO_82 = 82,
223  MHAL_GPIO_83 = 83,
224  MHAL_GPIO_84 = 84,
225  MHAL_GPIO_85 = 85,
226  MHAL_GPIO_86 = 86,
227  MHAL_GPIO_87 = 87,
228  MHAL_GPIO_88 = 88,
229  MHAL_GPIO_89 = 89,
230  MHAL_GPIO_90 = 90,
231  MHAL_GPIO_91 = 91,
232  MHAL_GPIO_92 = 92,
233  MHAL_GPIO_93 = 93,
236 } mhal_gpio_pin;
237 
238 typedef enum {
241  MHAL_GPIO_MODE_1 = 1,
242  MHAL_GPIO_MODE_2 = 2,
243  MHAL_GPIO_MODE_3 = 3,
244  MHAL_GPIO_MODE_4 = 4,
245  MHAL_GPIO_MODE_5 = 5,
246  MHAL_GPIO_MODE_6 = 6,
247  MHAL_GPIO_MODE_7 = 7,
251 
254 typedef enum {
260 
261 
264 typedef enum {
270 
273 typedef enum {
309 
310 
331 };
332 
336  void __iomem *base[MHAL_GPIO_REG_BASE_MAX];
338  unsigned int gpio_mode_bits;
340  unsigned int max_gpio_mode_per_reg;
342  unsigned char port_shf;
344  unsigned char port_mask;
346  unsigned int pinmux_offset;
347 };
348 
359 #ifdef __cplusplus
360 extern "C" {
361 #endif
362 
380  u32 pin, mhal_gpio_data *pvalue);
381 
401  u32 pin, u32 out_val);
402 
420  u32 pin, mhal_gpio_data *pvalue);
421 
441  struct mtk_pinctrl_controller *pctl, u32 pin, u32 dir);
442 
460  u32 pin, mhal_gpio_direction *pvalue);
461 
484  struct mtk_pinctrl_controller *pctl, u32 pin, bool enable, bool isup);
485 
507  struct mtk_pinctrl_controller *pctl, u32 pin, u32 mode);
508 
531  u32 pin, u32 *pvalue);
532 
533 #ifdef __cplusplus
534 }
535 #endif
536 
546 #endif
unsigned char port_shf
The shift between two registers.
Definition: mhal_gpio.h:342
int mtk_mhal_gpio_set_pullen_pullsel(struct mtk_pinctrl_controller *pctl, u32 pin, bool enable, bool isup)
This function is used to set the target GPIO to pull-up/pull-down state.
Define GPIO cm4 isu2 i2c base register.
Definition: mhal_gpio.h:291
Define GPIO cm4 gpio pwm group2 base register.
Definition: mhal_gpio.h:279
Define GPIO cm4 isu1 i2c base register.
Definition: mhal_gpio.h:289
mhal_gpio_mode
Definition: mhal_gpio.h:238
Define GPIO data of low.
Definition: mhal_gpio.h:266
Define GPIO input direction.
Definition: mhal_gpio.h:256
GPIO pin number is 0.
Definition: mhal_gpio.h:140
Define GPIO i2s0 base register.
Definition: mhal_gpio.h:301
int mtk_mhal_gpio_set_direction(struct mtk_pinctrl_controller *pctl, u32 pin, u32 dir)
This function is used to set the direction of the target GPIO.
Define GPIO output direction.
Definition: mhal_gpio.h:258
GPIO register maximum number(invalid)
Definition: mhal_gpio.h:307
bool pinctrl_free
GPIO can be requested or freed.
Definition: mhal_gpio.h:329
Define GPIO cm4 gpio pwm group4 base register.
Definition: mhal_gpio.h:283
mhal_gpio_data
This enum defines input or output data of GPIO.
Definition: mhal_gpio.h:264
Define GPIO pinmux base register.
Definition: mhal_gpio.h:305
int mtk_mhal_gpio_pmx_set_mode(struct mtk_pinctrl_controller *pctl, u32 pin, u32 mode)
This function is used to configure pinmux of the target GPIO.
Define GPIO adc base register.
Definition: mhal_gpio.h:297
Define GPIO cm4 isu3 i2c base register.
Definition: mhal_gpio.h:293
Define GPIO cm4 gpio pwm group5 base register.
Definition: mhal_gpio.h:285
int mtk_mhal_gpio_pmx_get_mode(struct mtk_pinctrl_controller *pctl, u32 pin, u32 *pvalue)
This function is used to get the configuration pinmux of the target GPIO.
void __iomem * base[MHAL_GPIO_REG_BASE_MAX]
GPIO controller base address.
Definition: mhal_gpio.h:336
This structure defines the GPIO interface controller.
Definition: mhal_gpio.h:334
int mtk_mhal_gpio_get_input(struct mtk_pinctrl_controller *pctl, u32 pin, mhal_gpio_data *pvalue)
This function is used to get input data of the target GPIO.
mhal_gpio_reg_base
This enum defines GPIO register base number.
Definition: mhal_gpio.h:273
GPIO mode number is from 0 to 7.
Definition: mhal_gpio.h:240
int mtk_mhal_gpio_get_output(struct mtk_pinctrl_controller *pctl, u32 pin, mhal_gpio_data *pvalue)
This function is used to get output data of the target GPIO.
Define GPIO i2s1 base register.
Definition: mhal_gpio.h:303
unsigned char port_mask
The mask of register.
Definition: mhal_gpio.h:344
mhal_gpio_pin
This enum defines the GPIO port.
Definition: mhal_gpio.h:138
GPIO pin maximum number(invalid)
Definition: mhal_gpio.h:235
Define GPIO data of high.
Definition: mhal_gpio.h:268
This structure defines GPIO pin related property.
Definition: mhal_gpio.h:324
unsigned int gpio_mode_bits
The number of gpio mode in per reg.
Definition: mhal_gpio.h:338
Define GPIO cm4 isu4 i2c base register.
Definition: mhal_gpio.h:295
Define GPIO cm4 gpio pwm group0 base register.
Definition: mhal_gpio.h:275
Define GPIO cm4 isu0 i2c base register.
Definition: mhal_gpio.h:287
Define GPIO ca7 base register.
Definition: mhal_gpio.h:299
mhal_gpio_direction
This enum defines GPIO direction.
Definition: mhal_gpio.h:254
unsigned int max_gpio_mode_per_reg
The max gpio mode in per reg.
Definition: mhal_gpio.h:340
int mtk_mhal_gpio_set_output(struct mtk_pinctrl_controller *pctl, u32 pin, u32 out_val)
This function is used to set output data of the target GPIO.
unsigned int pinmux_offset
The pinmux register offset.
Definition: mhal_gpio.h:346
GPIO mode maximum number(invalid)
Definition: mhal_gpio.h:249
int mtk_mhal_gpio_get_direction(struct mtk_pinctrl_controller *pctl, u32 pin, mhal_gpio_direction *pvalue)
This function is used to get the direction of the target GPIO.
Define GPIO cm4 gpio pwm group1 base register.
Definition: mhal_gpio.h:277
Define GPIO cm4 gpio pwm group3 base register.
Definition: mhal_gpio.h:281