Azure Sphere MT3620 M4 API Reference Manual
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
mhal_gpioif.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_GPIOIF_H__
37 #define __MHAL_GPIOIF_H__
38 #include "mhal_osai.h"
39 
133 #define GPIOIF_EINVAL 1
134 
135 #define GPIOIF_EPTR 2
136 
138 #define MAX_FIFO_ENTRY_CNT 16
139 
141 #define MAX_CTRL_SETTING 6
142 
144 #define MAX_MIN_PURSE_WIDTH 0x3fff
145 
147 #define IRQ_GPIOIF_EVENT_C_R_LOW (0)
148 
149 #define IRQ_GPIOIF_EVENT_C_R_HIGH (1)
150 
151 #define IRQ_GPIOIF_RESET_DONE (2)
152 
153 #define IRQ_GPIOIF_EVENT_C_OVERFLOW (8)
154 
155 #define IRQ_GPIOIF_EVENT_C_UNDERFLOW (9)
156 
159 #define IRQ_GPIOIF_W_CFIFO0_WHEN_FULL (12)
160 
163 #define IRQ_GPIOIF_W_CFIFO1_WHEN_FULL (13)
164 
167 #define IRQ_GPIOIF_W_GPIO_2_RESET_CFIFO0_WHEN_FULL (14)
168 
171 #define IRQ_GPIOIF_W_GPIO_2_RESET_CFIFO1_WHEN_FULL (15)
172 
173 #define IRQ_GPIOIF_CFIFO0_NOT_EMPTY (16)
174 
175 #define IRQ_GPIOIF_CFIFO1_NOT_EMPTY (17)
176 
177 #define IRQ_GPIOIF_R_CFIFO0_WHENEMPTY (24)
178 
179 #define IRQ_GPIOIF_R_CFIFO1_WHENEMPTY (25)
180 
181 #define IRQ_GPIOIF_ALL_ENABLE (1 << IRQ_GPIOIF_EVENT_C_R_LOW) |\
182  (1 << IRQ_GPIOIF_EVENT_C_R_HIGH) |\
183  (1 << IRQ_GPIOIF_RESET_DONE) |\
184  (1 << IRQ_GPIOIF_EVENT_C_OVERFLOW) |\
185  (1 << IRQ_GPIOIF_EVENT_C_UNDERFLOW) |\
186  (1 << IRQ_GPIOIF_W_CFIFO0_WHEN_FULL) |\
187  (1 << IRQ_GPIOIF_W_CFIFO1_WHEN_FULL) |\
188  (1 << IRQ_GPIOIF_W_GPIO_2_RESET_CFIFO0_WHEN_FULL) |\
189  (1 << IRQ_GPIOIF_W_GPIO_2_RESET_CFIFO1_WHEN_FULL) |\
190  (1 << IRQ_GPIOIF_CFIFO0_NOT_EMPTY) |\
191  (1 << IRQ_GPIOIF_CFIFO1_NOT_EMPTY) |\
192  (1 << IRQ_GPIOIF_R_CFIFO0_WHENEMPTY) |\
193  (1 << IRQ_GPIOIF_R_CFIFO1_WHENEMPTY)
194 
208 typedef enum {
220 
224 typedef enum {
240 
244 typedef enum {
254 
258 typedef enum {
268 
273 typedef enum {
287 
288 
293 typedef enum {
307 
311 typedef enum {
323 
327 typedef enum {
339 
351 typedef struct {
357  u8 updown;
369 
392 };
393 
399  u32 int_bit;
434 };
435 
436 
440  void __iomem *base[MHAL_GPIOIF_GROUP_MAX];
442  void __iomem *reg_clk_base;
447  struct mtk_gpioif_int_count *int_cnt;
448 };
449 
460 #ifdef __cplusplus
461 extern "C" {
462 #endif
463 
464 
482 
500 
518 
536 
554 
569 
584 
585 
604 
626  struct mtk_gpioif_controller *ctlr, u32 bit, u8 enable);
627 
647  struct mtk_gpioif_controller *ctlr, int active_reset);
648 
668  struct mtk_gpioif_controller *ctlr, unsigned int *pvalue);
669 
686  struct mtk_gpioif_controller *ctlr, unsigned int *pvalue);
687 
706  struct mtk_gpioif_controller *ctlr, unsigned int *pvalue);
707 
728  struct mtk_gpioif_controller *ctlr, int gpio, int enable,
729  unsigned int min_p, unsigned int init_v);
730 
746 
762 
781  struct mtk_gpioif_controller *ctlr, int enable);
782 
798 
816  struct mtk_gpioif_controller *ctlr, unsigned int *pvalue);
817 
835  struct mtk_gpioif_controller *ctlr, unsigned int *pvalue);
836 
855  struct mtk_gpioif_controller *ctlr, unsigned int *pvalue);
856 
857 #ifdef __cplusplus
858 }
859 #endif
860 
870 #endif
Capture on bith rising or falling edge.
Definition: mhal_gpioif.h:333
GPIOIF maximum clock source <invalid>
Definition: mhal_gpioif.h:218
Back to reset value when the counter reaches low limit value.
Definition: mhal_gpioif.h:281
Capture on falling edge.
Definition: mhal_gpioif.h:331
u32 int_event_uf_count
GPIOIF interrupt event underflow count value.
Definition: mhal_gpioif.h:409
mhal_gpioif_source_clock clk
GPIOIF clock source.
Definition: mhal_gpioif.h:373
u32 edge_type_gpio_1
Define edge type of GPIO_1 capture(0~3)
Definition: mhal_gpioif.h:367
int mtk_mhal_gpioif_read_reset_val(struct mtk_gpioif_controller *ctlr, unsigned int *pvalue)
This function is used to read reset value of GPIOIF Event Counter.
u32 high_limit
High limit value for GPIOIF Event Counter.
Definition: mhal_gpioif.h:363
Capture on rising edge.
Definition: mhal_gpioif.h:313
u32 cap_fifo1[MAX_FIFO_ENTRY_CNT]
GPIOIF store capture fifo1 value.
Definition: mhal_gpioif.h:429
GPIOIF Embedded XTAL KHz(26MHz) clock source.
Definition: mhal_gpioif.h:210
GPIOIF group2(gpio8~11)
Definition: mhal_gpioif.h:230
GPIOIF Both Event Counter Mode and Capture Counter Mode.
Definition: mhal_gpioif.h:264
Interrupt issued when the counter reaches low limit value.
Definition: mhal_gpioif.h:297
int mtk_mhal_gpioif_read_high_limit_val(struct mtk_gpioif_controller *ctlr, unsigned int *pvalue)
This function is used to read high limit value of GPIOIF Event Counter.
GPIOIF Embedded 32KHz clock source.
Definition: mhal_gpioif.h:212
int irq[MHAL_GPIOIF_GROUP_MAX]
GPIOIF controller group0~group5 irq number.
Definition: mhal_gpioif.h:444
int mtk_mhal_gpioif_disable_capture_counter(struct mtk_gpioif_controller *ctlr)
This function is used to disable capture counter mode.
GPIOIF maximum saturare mode limit selection <invalid>
Definition: mhal_gpioif.h:285
Capture on bith rising or falling edge.
Definition: mhal_gpioif.h:317
GPIOIF maximum edge type <invalid>
Definition: mhal_gpioif.h:321
int mtk_mhal_gpioif_read_gpio_cap_fifo0_value(struct mtk_gpioif_controller *ctlr, unsigned int *pvalue)
This function is used to read the GPIO capture fifo0 counter.
mhal_gpioif_group group
GPIOIF group.
Definition: mhal_gpioif.h:375
#define MAX_FIFO_ENTRY_CNT
This defines GPIOIF Capture Mode maximum available FIFO entry counter.
Definition: mhal_gpioif.h:138
Not interrupt.
Definition: mhal_gpioif.h:295
mhal_gpioif_gpio_0_edge_type gpio_0_edge_type
GPIOIF edge type of GPIO_0.
Definition: mhal_gpioif.h:387
int mtk_mhal_gpioif_counter_clock_setting(struct mtk_gpioif_controller *ctlr, int enable)
This function is used to enable/disable GPIOIF source clock.
u32 int_cap_f1_full_count
GPIOIF interrupt capture fifo1 count value.
Definition: mhal_gpioif.h:413
int mtk_mhal_gpioif_hardware_reset_by_gpio_2(struct mtk_gpioif_controller *ctlr, int active_reset)
This function uses GPIO_2 pin to reset GPIOIF event counter.
GPIOIF Direction mode.
Definition: mhal_gpioif.h:246
u32 low_limit
Low limit value for GPIOIF Event Counter.
Definition: mhal_gpioif.h:361
GPIOIF maximum edge type <invalid>
Definition: mhal_gpioif.h:337
struct mtk_gpioif_config * mconfig
GPIOIF configure property.
Definition: mhal_gpioif.h:446
int mtk_mhal_gpioif_select_clock_source(struct mtk_gpioif_controller *ctlr)
This function is used to select the GPIOIF clock source.
u32 int_bit
GPIOIF interrupt bit value.
Definition: mhal_gpioif.h:399
This structure defines the GPIOIF related parameters.
Definition: mhal_gpioif.h:351
u32 cap_fifo1_count
GPIOIF read capture fifo1 count value.
Definition: mhal_gpioif.h:433
u32 int_cap_f0_full_count
GPIOIF interrupt capture fifo0 count value.
Definition: mhal_gpioif.h:411
void __iomem * reg_clk_base
GPIOIF controller clk base address.
Definition: mhal_gpioif.h:442
GPIOIF maximum group <invalid>
Definition: mhal_gpioif.h:238
mhal_gpioif_group
This enum defines GPIOIF group selection.
Definition: mhal_gpioif.h:224
GPIOIF Capture Counter Mode.
Definition: mhal_gpioif.h:262
u32 int_reset_cap_f0_full_count
GPIOIF interrupt reset capture fifo0 count value.
Definition: mhal_gpioif.h:415
int mtk_mhal_gpioif_enable_capture_counter(struct mtk_gpioif_controller *ctlr)
This function is used to enable capture counter mode.
u32 int_cap_f1_np_count
GPIOIF interrupt capture fifo1 not empty count value.
Definition: mhal_gpioif.h:421
Saturare on high limit value.
Definition: mhal_gpioif.h:279
int mtk_mhal_gpioif_enable_event_counter(struct mtk_gpioif_controller *ctlr)
This function is used to enable event counter mode.
The common configuration can be set for the GPIOIF HW.
Definition: mhal_gpioif.h:371
GPIOIF Quadrature mode.
Definition: mhal_gpioif.h:250
u32 int_event_high_count
GPIOIF interrupt event high count value.
Definition: mhal_gpioif.h:403
u32 cap_fifo0[MAX_FIFO_ENTRY_CNT]
GPIOIF store capture fifo0 value.
Definition: mhal_gpioif.h:427
int mtk_mhal_gpioif_software_reset(struct mtk_gpioif_controller *ctlr)
This function is used to perform software reset of the GPIO event counter.
u32 int_reset_cap_f1_full_count
GPIOIF interrupt reset capture fifo1 count value.
Definition: mhal_gpioif.h:417
GPIOIF maximum supported Mode <invalid>
Definition: mhal_gpioif.h:266
u8 control_setting
Control edge type of GPIOIF Event Counter(1~6)
Definition: mhal_gpioif.h:353
Not saturare on limit value.
Definition: mhal_gpioif.h:275
GPIOIF group1(gpio4~7)
Definition: mhal_gpioif.h:228
mhal_gpioif_sa_mode_limit_select
This enum defines GPIOIF saturation mode selection of GPIO event counter when reaching limit value ...
Definition: mhal_gpioif.h:273
Capture on rising edge(reserved)
Definition: mhal_gpioif.h:335
int mtk_mhal_gpioif_capture_counter_setting(struct mtk_gpioif_controller *ctlr)
This function is used to set capture mode counter setting.
int mtk_mhal_gpioif_disable_event_counter(struct mtk_gpioif_controller *ctlr)
This function is used to disable event counter mode.
Capture on rising edge.
Definition: mhal_gpioif.h:329
mhal_gpioif_interrupt_limit_select
This enum defines GPIOIF interrupt mode selection of GPIO event counter.
Definition: mhal_gpioif.h:293
Interrupt issued when the counter reaches both low and high limit value.
Definition: mhal_gpioif.h:303
mhal_gpioif_event_counter_mode
This enum defines GPIOIF Event Counter Mode.
Definition: mhal_gpioif.h:244
GPIOIF maximum interrupt mode limit selection <invalid>
Definition: mhal_gpioif.h:305
mhal_gpioif_source_clock
This enum defines GPIOIF clock source selection.
Definition: mhal_gpioif.h:208
int mtk_mhal_gpioif_interrupt_bit_wise(struct mtk_gpioif_controller *ctlr, u32 bit, u8 enable)
This function is used to enable/disable bit-wise interrupt.
mhal_gpioif_gpio_0_edge_type
This enum defines the GPIOIF edge type of GPIO_0 capture.
Definition: mhal_gpioif.h:311
u32 int_cap_f0_p_count
GPIOIF interrupt capture fifo0 empty count value.
Definition: mhal_gpioif.h:423
This structure defines the GPIOIF related property.
Definition: mhal_gpioif.h:438
Back to reset value when the counter reaches high limit value.
Definition: mhal_gpioif.h:283
GPIOIF Event Counter Mode.
Definition: mhal_gpioif.h:260
mhal_gpioif_mode
This enum defines GPIOIF counter mode which can support.
Definition: mhal_gpioif.h:258
int mtk_mhal_gpioif_read_gpio_event_count(struct mtk_gpioif_controller *ctlr, unsigned int *pvalue)
This function is used to read the GPIO event counter value.
This structure defines the GPIOIF interrupt count related parameters.
Definition: mhal_gpioif.h:397
int mtk_mhal_gpioif_limit_comparator(struct mtk_gpioif_controller *ctlr)
This function is used to set interrupt mode or saturation mode of the GPIO event counter.
u32 reset_value
Reset value for GPIOIF Event Counter.
Definition: mhal_gpioif.h:359
mhal_gpioif_interrupt_limit_select inter_lim
GPIOIF interrupt mode selection of GPIO event counter.
Definition: mhal_gpioif.h:385
int mtk_mhal_gpioif_read_gpio_cap_fifo1_value(struct mtk_gpioif_controller *ctlr, unsigned int *pvalue)
This function is used to read the GPIO capture fifo1 counter.
GPIOIF group0(gpio0~3)
Definition: mhal_gpioif.h:226
Saturare on low limit value.
Definition: mhal_gpioif.h:277
mhal_gpioif_sa_mode_limit_select sa_mode_lim
GPIOIF saturation mode selection of GPIO event counter when reaching limit value. ...
Definition: mhal_gpioif.h:383
GPIOIF maximum Event Counter Mode <invalid>
Definition: mhal_gpioif.h:252
u32 int_event_low_count
GPIOIF interrupt event low count value.
Definition: mhal_gpioif.h:401
u32 edge_type_gpio_0
Define edge type of GPIO_0 capture(0~3)
Definition: mhal_gpioif.h:365
u8 updown
Definition of increment/decremnet GPIO pin for GPIOIF Event Counter in quadrature mode...
Definition: mhal_gpioif.h:357
int mtk_mhal_gpioif_de_glitch(struct mtk_gpioif_controller *ctlr, int gpio, int enable, unsigned int min_p, unsigned int init_v)
This function is used to set GPIOIF de-glitch setting.
mhal_gpioif_event_capture_setting * setting
GPIOIF event and capture setting.
Definition: mhal_gpioif.h:391
int mtk_mhal_gpioif_event_counter_setting(struct mtk_gpioif_controller *ctlr)
This function is used to set event counter mode setting.
GPIOIF group5(gpio20~23)
Definition: mhal_gpioif.h:236
mhal_gpioif_event_counter_mode event_cnt_mode
GPIOIF Event Counter Mode.
Definition: mhal_gpioif.h:377
mhal_gpioif_gpio_1_edge_type
This enum defines the GPIOIF edge type of GPIO_1 capture.
Definition: mhal_gpioif.h:327
GPIOIF group4(gpio16~19)
Definition: mhal_gpioif.h:234
GPIOIF 200MHz clock source.
Definition: mhal_gpioif.h:216
mhal_gpioif_gpio_1_edge_type gpio_1_edge_type
GPIOIF edge type of GPIO_1.
Definition: mhal_gpioif.h:389
u32 int_cap_f1_p_count
GPIOIF interrupt capture fifo1 empty count value.
Definition: mhal_gpioif.h:425
u32 int_gpio2_rst_done_count
GPIOIF gpio2 interrupt reset done count value.
Definition: mhal_gpioif.h:405
GPIOIF Up Down mode.
Definition: mhal_gpioif.h:248
u32 int_event_over_count
GPIOIF interrupt event overflow count value.
Definition: mhal_gpioif.h:407
int mtk_mhal_gpioif_isr_handle(struct mtk_gpioif_controller *ctlr)
This function is used to handle GPIOIF group0~5 interrupt.
Interrupt issued when the counter reaches high limit value.
Definition: mhal_gpioif.h:299
u32 cap_fifo0_count
GPIOIF read capture fifo0 count value.
Definition: mhal_gpioif.h:431
GPIOIF group3(gpio12~15)
Definition: mhal_gpioif.h:232
GPIOIF AXI1 MHz(125MHz) clock source.
Definition: mhal_gpioif.h:214
int mtk_mhal_gpioif_read_low_limit_val(struct mtk_gpioif_controller *ctlr, unsigned int *pvalue)
This function is used to read low limit value of GPIOIF Event Counter.
int mtk_mhal_gpioif_global_reset(struct mtk_gpioif_controller *ctlr)
This function is used to reset all GPIOIF group globally and make the register of the GPIOIF group to...
void __iomem * base[MHAL_GPIOIF_GROUP_MAX]
GPIOIF controller base address.
Definition: mhal_gpioif.h:440
Capture on rising edge(reserved)
Definition: mhal_gpioif.h:319
u32 int_cap_f0_np_count
GPIOIF interrupt capture fifo0 not empty count value.
Definition: mhal_gpioif.h:419
Capture on falling edge.
Definition: mhal_gpioif.h:315
mhal_gpioif_mode mode
GPIOIF mode.
Definition: mhal_gpioif.h:379