25 #include "in_compile.h" 32 #define GPIO_CFG_PIN_SHIFT 0 33 #define GPIO_CFG_PIN_MASK 0xF 34 #define GPIO_CFG_PORT_SHIFT 4 35 #define GPIO_CFG_PORT_MASK 0xF 36 #define GPIO_CFG_MUX_SHIFT 8 37 #define GPIO_CFG_MUX_MASK 0xF 38 #define GPIO_CFG_OE_IE_SHIFT 12 39 #define GPIO_CFG_OE_IE_MASK 0xF 40 #define GPIO_CFG_PD_PU_SHIFT 16 41 #define GPIO_CFG_PD_PU_MASK 0xF 42 #define GPIO_CFG_INV_SHIFT 20 43 #define GPIO_CFG_INV_MASK 0x1 44 #define GPIO_CFG_KEYBOARD_MUX_SHIFT 24 45 #define GPIO_CFG_KEYBOARD_MUX_MASK 0x3 47 #define QSPI_CFG_PIN_SHIFT 0 48 #define QSPI_CFG_PIN_MASK 0xF 49 #define QSPI_CFG_MUX_SHIFT 4 50 #define QSPI_CFG_MUX_MASK 0xF 51 #define QSPI_CFG_OE_IE_SHIFT 8 52 #define QSPI_CFG_OE_IE_MASK 0xF 53 #define QSPI_CFG_PD_PU_SHIFT 12 54 #define QSPI_CFG_PD_PU_MASK 0xF 56 #define GPIO_PORT_0_INT_RISE_EDGE_SHIFT 0 57 #define GPIO_PORT_0_INT_FALL_EDGE_SHIFT 9 58 #define GPIO_PORT_0_WUP_SHIFT 18 59 #define GPIO_PORT_0_INT_RISE_EDGE_MASK 0x1FF 60 #define GPIO_PORT_0_INT_FALL_EDGE_MASK (0x1FF << 9) 61 #define GPIO_PORT_0_WUP_MASK (0x1FF << 18) 62 #define GPIO_PORT_1_INT_RISE_EDGE_SHIFT 0 63 #define GPIO_PORT_1_INT_FALL_EDGE_SHIFT 10 64 #define GPIO_PORT_1_WUP_SHIFT 20 65 #define GPIO_PORT_1_INT_RISE_EDGE_MASK 0x3FF 66 #define GPIO_PORT_1_INT_FALL_EDGE_MASK (0x3FF << 10) 67 #define GPIO_PORT_1_WUP_MASK (0x3FF << 20) 68 #define GPIO_PORT_2_INT_RISE_EDGE_SHIFT 0 69 #define GPIO_PORT_2_INT_FALL_EDGE_SHIFT 10 70 #define GPIO_PORT_2_WUP_SHIFT 20 71 #define GPIO_PORT_2_INT_RISE_EDGE_MASK 0x3FF 72 #define GPIO_PORT_2_INT_FALL_EDGE_MASK (0x3FF << 10) 73 #define GPIO_PORT_2_WUP_MASK (0x3FF << 20) 74 #define GPIO_PORT_3_INT_RISE_EDGE_SHIFT 0 75 #define GPIO_PORT_3_INT_FALL_EDGE_SHIFT 6 76 #define GPIO_PORT_3_WUP_SHIFT 12 77 #define GPIO_PORT_3_INT_RISE_EDGE_MASK 0x3F 78 #define GPIO_PORT_3_INT_FALL_EDGE_MASK (0x3F << 6) 79 #define GPIO_PORT_3_WUP_MASK (0x3F << 12) 80 #define GPIO_PORT_4_INT_RISE_EDGE_SHIFT 0 81 #define GPIO_PORT_4_INT_FALL_EDGE_SHIFT 4 82 #define GPIO_PORT_4_WUP_SHIFT 8 83 #define GPIO_PORT_4_INT_RISE_EDGE_MASK 0xF 84 #define GPIO_PORT_4_INT_FALL_EDGE_MASK (0xF << 4) 85 #define GPIO_PORT_4_WUP_MASK (0xF << 8) 87 #define GPIO_PORT_0_NB_PINS 9 88 #define GPIO_PORT_1_NB_PINS 10 89 #define GPIO_PORT_2_NB_PINS 9 90 #define GPIO_PORT_3_NB_PINS 6 91 #define GPIO_PORT_4_NB_PINS 4 92 #define GPIO_NB_PINS (GPIO_PORT_0_NB_PINS+GPIO_PORT_1_NB_PINS+GPIO_PORT_2_NB_PINS+GPIO_PORT_3_NB_PINS+GPIO_PORT_4_NB_PINS) 151 enum gpio_slp_grp_0_port {
152 GPIO_SLP_GRP_0_PORT_0 = 0,
153 GPIO_SLP_GRP_0_PORT_1 = 1,
154 GPIO_SLP_GRP_0_PORT_3 = 3,
155 GPIO_SLP_GRP_0_PORT_4 = 4,
158 enum gpio_slp_grp_0_port_0_pins {
159 GPIO_SLP_GRP_0_PORT_0_PIN_0 = 0,
160 GPIO_SLP_GRP_0_PORT_0_PIN_4 = 4,
161 GPIO_SLP_GRP_0_PORT_0_PIN_8 = 8,
164 enum gpio_slp_grp_0_port_1_pins {
165 GPIO_SLP_GRP_0_PORT_1_PIN_2 = 2,
166 GPIO_SLP_GRP_0_PORT_1_PIN_6 = 6,
169 enum gpio_slp_grp_0_port_3_pins {
170 GPIO_SLP_GRP_0_PORT_3_PIN_5 = 5,
173 enum gpio_slp_grp_0_port_4_pins {
174 GPIO_SLP_GRP_0_PORT_4_PIN_1 = 1,
177 enum gpio_slp_grp_1_port {
178 GPIO_SLP_GRP_1_PORT_0 = 0,
179 GPIO_SLP_GRP_1_PORT_1 = 1,
180 GPIO_SLP_GRP_1_PORT_3 = 3,
181 GPIO_SLP_GRP_1_PORT_4 = 4,
184 enum gpio_slp_grp_1_port_0_pins {
185 GPIO_SLP_GRP_1_PORT_0_PIN_1 = 1,
186 GPIO_SLP_GRP_1_PORT_0_PIN_5 = 5,
189 enum gpio_slp_grp_1_port_1_pins {
190 GPIO_SLP_GRP_1_PORT_1_PIN_3 = 3,
191 GPIO_SLP_GRP_1_PORT_1_PIN_7 = 7,
194 enum gpio_slp_grp_1_port_3_pins {
195 GPIO_SLP_GRP_1_PORT_3_PIN_2 = 2,
198 enum gpio_slp_grp_1_port_4_pins {
199 GPIO_SLP_GRP_1_PORT_4_PIN_2 = 2,
202 enum gpio_slp_grp_2_port {
203 GPIO_SLP_GRP_2_PORT_0 = 0,
204 GPIO_SLP_GRP_2_PORT_1 = 1,
205 GPIO_SLP_GRP_2_PORT_3 = 3,
206 GPIO_SLP_GRP_2_PORT_4 = 4,
209 enum gpio_slp_grp_2_port_0_pins {
210 GPIO_SLP_GRP_2_PORT_0_PIN_2 = 2,
211 GPIO_SLP_GRP_2_PORT_0_PIN_6 = 6,
214 enum gpio_slp_grp_2_port_1_pins {
215 GPIO_SLP_GRP_2_PORT_1_PIN_0 = 0,
216 GPIO_SLP_GRP_2_PORT_1_PIN_4 = 4,
217 GPIO_SLP_GRP_2_PORT_1_PIN_8 = 8,
220 enum gpio_slp_grp_2_port_3_pins {
221 GPIO_SLP_GRP_2_PORT_3_PIN_3 = 3,
224 enum gpio_slp_grp_2_port_4_pins {
225 GPIO_SLP_GRP_2_PORT_4_PIN_3 = 3,
228 enum gpio_slp_grp_3_port {
229 GPIO_SLP_GRP_3_PORT_0 = 0,
230 GPIO_SLP_GRP_3_PORT_1 = 1,
231 GPIO_SLP_GRP_3_PORT_3 = 3,
232 GPIO_SLP_GRP_3_PORT_4 = 4,
235 enum gpio_slp_grp_3_port_0_pins {
236 GPIO_SLP_GRP_3_PORT_0_PIN_3 = 3,
237 GPIO_SLP_GRP_3_PORT_0_PIN_7 = 7,
240 enum gpio_slp_grp_3_port_1_pins {
241 GPIO_SLP_GRP_3_PORT_1_PIN_1 = 1,
242 GPIO_SLP_GRP_3_PORT_1_PIN_5 = 5,
243 GPIO_SLP_GRP_3_PORT_1_PIN_9 = 9,
246 enum gpio_slp_grp_3_port_3_pins {
247 GPIO_SLP_GRP_3_PORT_3_PIN_4 = 4,
250 enum gpio_slp_grp_3_port_4_pins {
251 GPIO_SLP_GRP_3_PORT_4_PIN_0 = 0,
254 enum gpio_slp_grp_0_pin_mux {
255 GPIO_SLP_GRP_0_MUX_NONE = 0,
256 GPIO_SLP_GRP_0_MUX_AON_CLK = 1,
257 GPIO_SLP_GRP_0_MUX_PD1_WDT_RESET_PD0 = 2,
258 GPIO_SLP_GRP_0_MUX_SQ_WAVE = 3,
259 GPIO_SLP_GRP_0_MUX_PD1_WDT_RESET_PD1 = 4,
260 GPIO_SLP_GRP_0_MUX_DCDC_EN = 5,
261 GPIO_SLP_GRP_0_MUX_WDT_RESET_PD0 = 6,
262 GPIO_SLP_GRP_0_MUX_WDT_RESET_PD0_INV = 7,
265 enum gpio_slp_grp_1_pin_mux {
266 GPIO_SLP_GRP_1_MUX_NONE = 0,
267 GPIO_SLP_GRP_1_MUX_PD1_RESET = 1,
268 GPIO_SLP_GRP_1_MUX_PD1_RESET_INV = 2,
269 GPIO_SLP_GRP_1_MUX_FLASH_POW = 3,
270 GPIO_SLP_GRP_1_MUX_OSC_EN = 4,
271 GPIO_SLP_GRP_1_MUX_SQ_WAVE = 5,
272 GPIO_SLP_GRP_1_MUX_WUP_REQ = 6,
273 GPIO_SLP_GRP_1_MUX_BLE_CLK_ON = 7,
276 enum gpio_slp_grp_2_pin_mux {
277 GPIO_SLP_GRP_2_MUX_NONE = 0,
278 GPIO_SLP_GRP_2_MUX_SLP_REQ = 1,
279 GPIO_SLP_GRP_2_MUX_RTC_CLK = 2,
280 GPIO_SLP_GRP_2_MUX_RC_CLK = 3,
281 GPIO_SLP_GRP_2_MUX_AON_TIMER_0_TMO = 4,
282 GPIO_SLP_GRP_2_MUX_AON_TIMER_1_TMO = 5,
283 GPIO_SLP_GRP_2_MUX_AON_TIMER_2_TMO = 6,
284 GPIO_SLP_GRP_2_MUX_AON_TIMER_3_TMO = 7,
287 enum gpio_slp_grp_3_pin_mux {
288 GPIO_SLP_GRP_3_MUX_NONE = 0,
289 GPIO_SLP_GRP_3_MUX_EM_16K_EN = 1,
290 GPIO_SLP_GRP_3_MUX_EM_16K_RETN = 2,
291 GPIO_SLP_GRP_3_MUX_DM_32K_A_EN = 3,
292 GPIO_SLP_GRP_3_MUX_DM_32K_RETN = 4,
293 GPIO_SLP_GRP_3_MUX_DM_32K_B_EN = 5,
294 GPIO_SLP_GRP_3_MUX_DM_32K_B_RETN = 6,
295 GPIO_SLP_GRP_3_MUX_SENSOR_POW = 7,
299 GPIO_ERR_NO_ERROR = 0,
300 GPIO_ERR_INVALID_PARAM = -1,
322 static INLINE
void gpio_port_0_pin_mux(
int pin,
int mux,
int inv)
328 addr = GLOBAL_REG_PIN_MUX_GPIO_01_CONT;
330 addr = GLOBAL_REG_PIN_MUX_GPIO_0;
333 uint32_t reg = RD_WORD(addr);
335 reg &= ~(0x7 << (pin << 2));
336 reg |= ((mux & 0x7) << (pin << 2));
338 reg |= (1 << ((pin << 2) + 3));
340 reg &= ~(1 << ((pin << 2) + 3));
345 static INLINE
void gpio_port_1_pin_mux(
int pin,
int mux,
int inv)
352 addr = GLOBAL_REG_PIN_MUX_GPIO_01_CONT;
354 addr = GLOBAL_REG_PIN_MUX_GPIO_1;
357 uint32_t reg = RD_WORD(addr);
359 reg &= ~(0x7 << (pin << 2));
360 reg |= ((mux & 0x7) << (pin << 2));
362 reg |= (1 << ((pin << 2) + 3));
364 reg &= ~(1 << ((pin << 2) + 3));
371 static INLINE
void gpio_port_2_pin_mux(
int pin,
int mux,
int inv)
377 addr = GLOBAL_REG_PIN_MUX_GPIO_23_CONT;
379 addr = GLOBAL_REG_PIN_MUX_GPIO_2;
382 uint32_t reg = RD_WORD(addr);
384 reg &= ~(0x7 << (pin << 2));
385 reg |= ((mux & 0x7) << (pin << 2));
387 reg |= (1 << ((pin << 2) + 3));
389 reg &= ~(1 << ((pin << 2) + 3));
395 static INLINE
void gpio_port_3_pin_mux(
int pin,
int mux,
int inv)
397 uint32_t reg = RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_23_CONT);
400 reg &= ~(0x7 << (pin << 2));
401 reg |= ((mux & 0x7) << (pin << 2));
403 reg |= (1 << ((pin << 2) + 3));
405 reg &= ~(1 << ((pin << 2) + 3));
407 WR_WORD(GLOBAL_REG_PIN_MUX_GPIO_23_CONT, reg);
410 static INLINE
void gpio_port_4_pin_mux(
int pin,
int mux,
int inv)
412 uint32_t reg = RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_4);
414 reg &= ~(0x7 << (pin << 2));
415 reg |= ((mux & 0x7) << (pin << 2));
417 reg |= (1 << ((pin << 2) + 3));
419 reg &= ~(1 << ((pin << 2) + 3));
421 WR_WORD(GLOBAL_REG_PIN_MUX_GPIO_4, reg);
424 static INLINE uint32_t gpio_port_0_pin_mux_get(
void)
426 return (RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_0));
429 static INLINE uint32_t gpio_port_0_pin_mux_cont_get(
void)
431 return (RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_01_CONT) & 0xF);
434 static INLINE uint32_t gpio_port_1_pin_mux_get(
void)
436 return (RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_1));
439 static INLINE uint32_t gpio_port_1_pin_mux_cont_get(
void)
441 return ((RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_01_CONT) >> 4));
444 static INLINE uint32_t gpio_port_2_pin_mux_get(
void)
446 return (RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_2));
449 static INLINE uint32_t gpio_port_2_pin_mux_cont_get(
void)
451 return (RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_23_CONT) & 0xF);
454 static INLINE uint32_t gpio_port_3_pin_mux_get(
void)
456 return ((RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_23_CONT) >> 4));
459 static INLINE uint32_t gpio_port_4_pin_mux_get(
void)
461 return (RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_4));
464 static INLINE
void gpio_port_0_output_enable(
int pin)
466 WR_WORD(GLOBAL_REG_GPIO_0_OUTPUT_SET, (1 << (GLOBAL_REG_GPIO_0_OUTPUT_SET_CTL_GPIO_0_OUTPUT_EN_SET_SHIFT + pin)));
469 static INLINE
void gpio_port_0_output_disable(
int pin)
471 WR_WORD(GLOBAL_REG_GPIO_0_OUTPUT_CLEAR, (1 << (GLOBAL_REG_GPIO_0_OUTPUT_CLEAR_CTL_GPIO_0_OUTPUT_EN_CLEAR_SHIFT + pin)));
475 static INLINE
void gpio_port_0_output(
int pin,
int high)
478 WR_WORD(GLOBAL_REG_GPIO_0_OUTPUT_SET, (1 << pin));
480 WR_WORD(GLOBAL_REG_GPIO_0_OUTPUT_CLEAR, (1 << pin));
484 static INLINE
int gpio_port_0_output_status(
int pin)
486 return ((RD_WORD(GLOBAL_REG_GPIO_0_IO_STATUS) >> (GLOBAL_REG_GPIO_0_IO_STATUS_STS_GPIO_0_CURR_OUTPUT_SHIFT + pin)) & 1);
489 static INLINE
void gpio_port_1_output_enable(
int pin)
491 WR_WORD(GLOBAL_REG_GPIO_1_OUTPUT_SET, (1 << (GLOBAL_REG_GPIO_1_OUTPUT_SET_CTL_GPIO_1_OUTPUT_EN_SET_SHIFT + pin)));
494 static INLINE
void gpio_port_1_output_disable(
int pin)
496 WR_WORD(GLOBAL_REG_GPIO_1_OUTPUT_CLEAR, (1 << (GLOBAL_REG_GPIO_1_OUTPUT_CLEAR_CTL_GPIO_1_OUTPUT_EN_CLEAR_SHIFT + pin)));
500 static INLINE
void gpio_port_1_output(
int pin,
int high)
503 WR_WORD(GLOBAL_REG_GPIO_1_OUTPUT_SET, (1 << pin));
505 WR_WORD(GLOBAL_REG_GPIO_1_OUTPUT_CLEAR, (1 << pin));
509 static INLINE
int gpio_port_1_output_status(
int pin)
511 return ((RD_WORD(GLOBAL_REG_GPIO_1_IO_STATUS) >> (GLOBAL_REG_GPIO_1_IO_STATUS_STS_GPIO_1_CURR_OUTPUT_SHIFT + pin)) & 1);
514 static INLINE
void gpio_port_2_output_enable(
int pin)
516 WR_WORD(GLOBAL_REG_GPIO_2_OUTPUT_SET, (1 << (GLOBAL_REG_GPIO_2_OUTPUT_SET_CTL_GPIO_2_OUTPUT_EN_SET_SHIFT + pin)));
519 static INLINE
void gpio_port_2_output_disable(
int pin)
521 WR_WORD(GLOBAL_REG_GPIO_2_OUTPUT_CLEAR, (1 << (GLOBAL_REG_GPIO_2_OUTPUT_CLEAR_CTL_GPIO_2_OUTPUT_EN_CLEAR_SHIFT + pin)));
525 static INLINE
void gpio_port_2_output(
int pin,
int high)
528 WR_WORD(GLOBAL_REG_GPIO_2_OUTPUT_SET, (1 << pin));
530 WR_WORD(GLOBAL_REG_GPIO_2_OUTPUT_CLEAR, (1 << pin));
534 static INLINE
int gpio_port_2_output_status(
int pin)
536 return ((RD_WORD(GLOBAL_REG_GPIO_2_IO_STATUS) >> (GLOBAL_REG_GPIO_2_IO_STATUS_STS_GPIO_2_CURR_OUTPUT_SHIFT + pin)) & 1);
539 static INLINE
void gpio_port_3_output_enable(
int pin)
541 WR_WORD(GLOBAL_REG_GPIO_34_OUTPUT_SET, (1 << (GLOBAL_REG_GPIO_34_OUTPUT_SET_CTL_GPIO_3_OUTPUT_EN_SET_SHIFT + pin)));
544 static INLINE
void gpio_port_3_output_disable(
int pin)
546 WR_WORD(GLOBAL_REG_GPIO_34_OUTPUT_CLEAR, (1 << (GLOBAL_REG_GPIO_34_OUTPUT_CLEAR_CTL_GPIO_3_OUTPUT_EN_CLEAR_SHIFT + pin)));
549 static INLINE
void gpio_port_3_output(
int pin,
int high)
552 WR_WORD(GLOBAL_REG_GPIO_34_OUTPUT_SET, (1 << pin));
554 WR_WORD(GLOBAL_REG_GPIO_34_OUTPUT_CLEAR, (1 << pin));
558 static INLINE
int gpio_port_3_output_status(
int pin)
560 return ((RD_WORD(GLOBAL_REG_GPIO_34_IO_STATUS) >> (GLOBAL_REG_GPIO_34_IO_STATUS_STS_GPIO_3_CURR_OUTPUT_SHIFT + pin)) & 1);
563 static INLINE
void gpio_port_4_output_enable(
int pin)
565 WR_WORD(GLOBAL_REG_GPIO_34_OUTPUT_SET, (1 << (GLOBAL_REG_GPIO_34_OUTPUT_SET_CTL_GPIO_4_OUTPUT_EN_SET_SHIFT + pin)));
568 static INLINE
void gpio_port_4_output_disable(
int pin)
570 WR_WORD(GLOBAL_REG_GPIO_34_OUTPUT_CLEAR, (1 << (GLOBAL_REG_GPIO_34_OUTPUT_CLEAR_CTL_GPIO_4_OUTPUT_EN_CLEAR_SHIFT + pin)));
573 static INLINE
void gpio_port_4_output(
int pin,
int high)
576 WR_WORD(GLOBAL_REG_GPIO_34_OUTPUT_SET, (1 << (pin + GLOBAL_REG_GPIO_34_OUTPUT_SET_CTL_GPIO_4_OUTPUT_SET_SHIFT)));
578 WR_WORD(GLOBAL_REG_GPIO_34_OUTPUT_CLEAR, (1 << (pin + GLOBAL_REG_GPIO_34_OUTPUT_CLEAR_CTL_GPIO_4_OUTPUT_CLEAR_SHIFT)));
582 static INLINE
int gpio_port_4_output_status(
int pin)
584 return ((RD_WORD(GLOBAL_REG_GPIO_34_IO_STATUS) >> (GLOBAL_REG_GPIO_34_IO_STATUS_STS_GPIO_4_CURR_OUTPUT_SHIFT + pin)) & 1);
587 static INLINE
int gpio_port_0_input(
int pin)
589 return ((RD_WORD(GLOBAL_REG_GPIO_0_IO_STATUS) >> pin) & 1);
592 static INLINE
int gpio_port_1_input(
int pin)
594 return ((RD_WORD(GLOBAL_REG_GPIO_1_IO_STATUS) >> pin) & 1);
597 static INLINE
int gpio_port_2_input(
int pin)
599 return ((RD_WORD(GLOBAL_REG_GPIO_2_IO_STATUS) >> pin) & 1);
602 static INLINE
int gpio_port_3_input(
int pin)
604 return ((RD_WORD(GLOBAL_REG_GPIO_34_IO_STATUS) >> pin) & 1);
607 static INLINE
int gpio_port_4_input(
int pin)
609 return ((RD_WORD(GLOBAL_REG_GPIO_34_IO_STATUS) >> (pin + GLOBAL_REG_GPIO_34_IO_STATUS_STS_GPIO_4_INPUT_SHIFT)) & 1);
612 static INLINE
void gpio_port_0_pad_oe_ie(
int pin,
int oe,
int ie)
614 uint32_t reg = RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_0_OE_IE);
622 reg |= (1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_0_OE_IE_CTL_GPIO_TO_PAD_IE_0_SHIFT));
624 reg &= ~(1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_0_OE_IE_CTL_GPIO_TO_PAD_IE_0_SHIFT));
626 WR_WORD(GLOBAL_REG_PIN_MUX_GPIO_0_OE_IE, reg);
629 static INLINE uint32_t gpio_port_0_pad_oe_ie_get(
void)
631 return (RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_0_OE_IE));
634 static INLINE
void gpio_port_1_pad_oe_ie(
int pin,
int oe,
int ie)
636 uint32_t reg = RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_1_OE_IE);
644 reg |= (1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_1_OE_IE_CTL_GPIO_TO_PAD_IE_1_SHIFT));
646 reg &= ~(1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_1_OE_IE_CTL_GPIO_TO_PAD_IE_1_SHIFT));
648 WR_WORD(GLOBAL_REG_PIN_MUX_GPIO_1_OE_IE, reg);
652 static INLINE uint32_t gpio_port_1_pad_oe_ie_get(
void)
654 return (RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_1_OE_IE));
657 static INLINE
void gpio_port_2_pad_oe_ie(
int pin,
int oe,
int ie)
659 uint32_t reg = RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_2_OE_IE);
667 reg |= (1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_2_OE_IE_CTL_GPIO_TO_PAD_IE_2_SHIFT));
669 reg &= ~(1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_2_OE_IE_CTL_GPIO_TO_PAD_IE_2_SHIFT));
671 WR_WORD(GLOBAL_REG_PIN_MUX_GPIO_2_OE_IE, reg);
675 static INLINE uint32_t gpio_port_2_pad_oe_ie_get(
void)
677 return (RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_2_OE_IE));
680 static INLINE
void gpio_port_3_pad_oe_ie(
int pin,
int oe,
int ie)
682 uint32_t reg = RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_34_OE_IE);
690 reg |= (1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_34_OE_IE_CTL_GPIO_TO_PAD_IE_3_SHIFT));
692 reg &= ~(1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_34_OE_IE_CTL_GPIO_TO_PAD_IE_3_SHIFT));
694 WR_WORD(GLOBAL_REG_PIN_MUX_GPIO_34_OE_IE, reg);
698 static INLINE
void gpio_port_4_pad_oe_ie(
int pin,
int oe,
int ie)
700 uint32_t reg = RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_34_OE_IE);
703 reg |= (1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_34_OE_IE_CTL_GPIO_TO_PAD_OE_4_SHIFT));
705 reg &= ~(1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_34_OE_IE_CTL_GPIO_TO_PAD_OE_4_SHIFT));
708 reg |= (1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_34_OE_IE_CTL_GPIO_TO_PAD_IE_4_SHIFT));
710 reg &= ~(1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_34_OE_IE_CTL_GPIO_TO_PAD_IE_4_SHIFT));
712 WR_WORD(GLOBAL_REG_PIN_MUX_GPIO_34_OE_IE, reg);
715 static INLINE uint32_t gpio_port_34_pad_oe_ie_get(
void)
717 return (RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_34_OE_IE));
720 static INLINE
void gpio_port_0_pad_pd_pu(
int pin,
int pd,
int pu)
722 uint32_t reg = RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_0_PD_PU);
729 reg |= (1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_0_PD_PU_CTL_GPIO_TO_PAD_PU_0_SHIFT));
731 reg &= ~(1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_0_PD_PU_CTL_GPIO_TO_PAD_PU_0_SHIFT));
733 WR_WORD(GLOBAL_REG_PIN_MUX_GPIO_0_PD_PU, reg);
736 static INLINE uint32_t gpio_port_0_pad_pd_pu_get(
void)
738 return (RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_0_PD_PU));
741 static INLINE
void gpio_port_1_pad_pd_pu(
int pin,
int pd,
int pu)
743 uint32_t reg = RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_1_PD_PU);
750 reg |= (1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_1_PD_PU_CTL_GPIO_TO_PAD_PU_1_SHIFT));
752 reg &= ~(1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_1_PD_PU_CTL_GPIO_TO_PAD_PU_1_SHIFT));
754 WR_WORD(GLOBAL_REG_PIN_MUX_GPIO_1_PD_PU, reg);
757 static INLINE uint32_t gpio_port_1_pad_pd_pu_get(
void)
759 return (RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_1_PD_PU));
762 static INLINE
void gpio_port_2_pad_pd_pu(
int pin,
int pd,
int pu)
764 uint32_t reg = RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_2_PD_PU);
771 reg |= (1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_2_PD_PU_CTL_GPIO_TO_PAD_PU_2_SHIFT));
773 reg &= ~(1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_2_PD_PU_CTL_GPIO_TO_PAD_PU_2_SHIFT));
775 WR_WORD(GLOBAL_REG_PIN_MUX_GPIO_2_PD_PU, reg);
778 static INLINE uint32_t gpio_port_2_pad_pd_pu_get(
void)
780 return (RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_2_PD_PU));
783 static INLINE
void gpio_port_3_pad_pd_pu(
int pin,
int pd,
int pu)
785 uint32_t reg = RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_34_PD_PU);
792 reg |= (1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_34_PD_PU_CTL_GPIO_TO_PAD_PU_3_SHIFT));
794 reg &= ~(1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_34_PD_PU_CTL_GPIO_TO_PAD_PU_3_SHIFT));
796 WR_WORD(GLOBAL_REG_PIN_MUX_GPIO_34_PD_PU, reg);
799 static INLINE
void gpio_port_4_pad_pd_pu(
int pin,
int pd,
int pu)
801 uint32_t reg = RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_34_PD_PU);
803 reg |= (1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_34_PD_PU_CTL_GPIO_TO_PAD_PD_4_SHIFT));
805 reg &= ~(1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_34_PD_PU_CTL_GPIO_TO_PAD_PD_4_SHIFT));
808 reg |= (1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_34_PD_PU_CTL_GPIO_TO_PAD_PU_4_SHIFT));
810 reg &= ~(1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_34_PD_PU_CTL_GPIO_TO_PAD_PU_4_SHIFT));
812 WR_WORD(GLOBAL_REG_PIN_MUX_GPIO_34_PD_PU, reg);
815 static INLINE uint32_t gpio_port_34_pad_pd_pu_get(
void)
817 return (RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_34_PD_PU));
820 static INLINE
void gpio_port_0_pad_pc(
int pin,
int on)
822 uint32_t reg = RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_PC_01);
824 pin &= GLOBAL_REG_PIN_MUX_GPIO_PC_01_CTL_GPIO_TO_PAD_PC_0_MASK;
830 WR_WORD(GLOBAL_REG_PIN_MUX_GPIO_PC_01, reg);
833 static INLINE
void gpio_port_1_pad_pc(
int pin,
int on)
835 uint32_t reg = RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_PC_01);
837 pin &= GLOBAL_REG_PIN_MUX_GPIO_PC_01_CTL_GPIO_TO_PAD_PC_1_MASK;
839 reg |= (1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_PC_01_CTL_GPIO_TO_PAD_PC_1_SHIFT));
841 reg &= ~(1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_PC_01_CTL_GPIO_TO_PAD_PC_1_SHIFT));
843 WR_WORD(GLOBAL_REG_PIN_MUX_GPIO_PC_01, reg);
846 static INLINE uint32_t gpio_port_01_pad_pc_get(
void)
848 return (RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_PC_01));
851 static INLINE
void gpio_port_2_pad_pc(
int pin,
int on)
853 uint32_t reg = RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_PC_234);
855 pin &= GLOBAL_REG_PIN_MUX_GPIO_PC_234_CTL_GPIO_TO_PAD_PC_2_MASK;
861 WR_WORD(GLOBAL_REG_PIN_MUX_GPIO_PC_234, reg);
864 static INLINE
void gpio_port_3_pad_pc(
int pin,
int on)
866 uint32_t reg = RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_PC_234);
868 pin &= GLOBAL_REG_PIN_MUX_GPIO_PC_234_CTL_GPIO_TO_PAD_PC_3_MASK;
870 reg |= (1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_PC_234_CTL_GPIO_TO_PAD_PC_3_SHIFT));
872 reg &= ~(1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_PC_234_CTL_GPIO_TO_PAD_PC_3_SHIFT));
874 WR_WORD(GLOBAL_REG_PIN_MUX_GPIO_PC_234, reg);
877 static INLINE
void gpio_port_4_pad_pc(
int pin,
int on)
879 uint32_t reg = RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_PC_234);
881 pin &= GLOBAL_REG_PIN_MUX_GPIO_PC_234_CTL_GPIO_TO_PAD_PC_4_MASK;
883 reg |= (1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_PC_234_CTL_GPIO_TO_PAD_PC_4_SHIFT));
885 reg &= ~(1 << (pin + GLOBAL_REG_PIN_MUX_GPIO_PC_234_CTL_GPIO_TO_PAD_PC_4_SHIFT));
887 WR_WORD(GLOBAL_REG_PIN_MUX_GPIO_PC_234, reg);
890 static INLINE uint32_t gpio_port_23_pad_pc_get(
void)
892 return (RD_WORD(GLOBAL_REG_PIN_MUX_GPIO_PC_234));
895 static INLINE
void gpio_qspi_pin_pad_pc(uint8_t pc_mask)
897 uint32_t reg = RD_WORD(GLOBAL_REG_QSPI_PC);
899 reg &= ~GLOBAL_REG_QSPI_PC_CTL_QSPI_PC;
900 reg |= (pc_mask & GLOBAL_REG_QSPI_PC_CTL_QSPI_PC_MASK) << GLOBAL_REG_QSPI_PC_CTL_QSPI_PC_SHIFT;
902 WR_WORD(GLOBAL_REG_QSPI_PC, reg);
905 static INLINE
void gpio_qspi_pin_pad_pc_set(uint32_t reg)
907 WR_WORD(GLOBAL_REG_QSPI_PC, reg);
910 static INLINE uint32_t gpio_qspi_pin_pad_pc_get(
void)
912 return RD_WORD(GLOBAL_REG_QSPI_PC);
915 static INLINE
void gpio_qspi_pin_mux(uint8_t mux0, uint8_t mux2, uint8_t mux3, uint8_t mux4, uint8_t mux5)
917 uint32_t reg = RD_WORD(GLOBAL_REG_PIN_MUX_QSPI);
920 reg &= ~GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_0_SEL;
921 reg |= (mux0 & GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_0_SEL_MASK) << GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_0_SEL_SHIFT;
923 reg |= GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_0_INV;
925 reg &= ~GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_0_INV;
927 reg &= ~GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_1_SEL;
928 reg |= (1 & GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_1_SEL_MASK) << GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_1_SEL_SHIFT;
930 reg &= ~GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_2_SEL;
931 reg |= (mux2 & GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_2_SEL_MASK) << GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_2_SEL_SHIFT;
933 reg |= GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_2_INV;
935 reg &= ~GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_2_INV;
937 reg &= ~GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_3_SEL;
938 reg |= (mux3 & GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_3_SEL_MASK) << GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_3_SEL_SHIFT;
940 reg |= GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_3_INV;
942 reg &= ~GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_3_INV;
944 reg &= ~GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_4_SEL;
945 reg |= (mux4 & GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_4_SEL_MASK) << GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_4_SEL_SHIFT;
947 reg |= GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_4_INV;
949 reg &= ~GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_4_INV;
951 reg &= ~GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_5_SEL;
952 reg |= (mux5 & GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_5_SEL_MASK) << GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_5_SEL_SHIFT;
954 reg |= GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_5_INV;
956 reg &= ~GLOBAL_REG_PIN_MUX_QSPI_CTL_PIN_MUX_QSPI_5_INV;
959 reg |= GLOBAL_REG_PIN_MUX_QSPI_CTL_QSPI_EFUSE0REG1;
962 WR_WORD(GLOBAL_REG_PIN_MUX_QSPI, reg);
965 static INLINE
void gpio_qspi_pin_mux_set(uint32_t reg)
967 WR_WORD(GLOBAL_REG_PIN_MUX_QSPI, reg);
970 static INLINE uint32_t gpio_qspi_pin_mux_get(
void)
972 return RD_WORD(GLOBAL_REG_PIN_MUX_QSPI);
975 static INLINE
void gpio_qspi_pin_pad_ie_oe_pu_pd(uint8_t oe_mask, uint8_t ie_mask, uint8_t pu_mask, uint8_t pd_mask)
977 uint32_t reg = RD_WORD(GLOBAL_REG_QSPI_OE_IE_PU_PD);
980 reg &= ~GLOBAL_REG_QSPI_OE_IE_PU_PD_CTL_QSPI_OE;
981 reg |= (oe_mask & GLOBAL_REG_QSPI_OE_IE_PU_PD_CTL_QSPI_OE_MASK) << GLOBAL_REG_QSPI_OE_IE_PU_PD_CTL_QSPI_OE_SHIFT;
983 reg &= ~GLOBAL_REG_QSPI_OE_IE_PU_PD_CTL_QSPI_IE;
984 reg |= (ie_mask & GLOBAL_REG_QSPI_OE_IE_PU_PD_CTL_QSPI_IE_MASK) << GLOBAL_REG_QSPI_OE_IE_PU_PD_CTL_QSPI_IE_SHIFT;
986 reg &= ~GLOBAL_REG_QSPI_OE_IE_PU_PD_CTL_QSPI_PU;
987 reg |= (pu_mask & GLOBAL_REG_QSPI_OE_IE_PU_PD_CTL_QSPI_PU_MASK) << GLOBAL_REG_QSPI_OE_IE_PU_PD_CTL_QSPI_PU_SHIFT;
989 reg &= ~GLOBAL_REG_QSPI_OE_IE_PU_PD_CTL_QSPI_PD;
990 reg |= (pd_mask & GLOBAL_REG_QSPI_OE_IE_PU_PD_CTL_QSPI_PD_MASK) << GLOBAL_REG_QSPI_OE_IE_PU_PD_CTL_QSPI_PD_SHIFT;
992 WR_WORD(GLOBAL_REG_QSPI_OE_IE_PU_PD, reg);
995 static INLINE
void gpio_qspi_pin_pad_ie_oe_pu_pd_set(uint32_t reg)
997 WR_WORD(GLOBAL_REG_QSPI_OE_IE_PU_PD, reg);
1000 static INLINE uint32_t gpio_qspi_pin_pad_ie_oe_pu_pd_get(
void)
1002 return (RD_WORD(GLOBAL_REG_QSPI_OE_IE_PU_PD));
1005 static INLINE uint32_t gpio_port_0_int_status(
void)
1007 return (RD_WORD(GLOBAL_REG_INTR_GPIO_0_STATUS));
1010 static INLINE
void gpio_port_0_int_clear(uint32_t pin)
1012 uint32_t reg = (1 << pin) | (1 << (pin + GPIO_PORT_0_INT_FALL_EDGE_SHIFT)) | (1 << (pin + GPIO_PORT_0_WUP_SHIFT));
1013 WR_WORD(GLOBAL_REG_INTR_GPIO_0_CLEAR, reg);
1016 static INLINE
void gpio_port_0_int_clear_all(
void)
1018 WR_WORD(GLOBAL_REG_INTR_GPIO_0_CLEAR, GLOBAL_REG_INTR_GPIO_0_CLEAR_IRQ);
1021 static INLINE uint32_t gpio_port_0_int_mask_status(
void)
1023 return (RD_WORD(GLOBAL_REG_INTR_GPIO_0_MASK_STATUS));
1026 static INLINE
void gpio_port_0_int_mask_all(
void)
1028 WR_WORD(GLOBAL_REG_INTR_GPIO_0_MASK_SET, GLOBAL_REG_INTR_GPIO_0_MASK_SET_IRQ);
1031 static INLINE
void gpio_port_0_int_mask(uint32_t mask)
1033 WR_WORD(GLOBAL_REG_INTR_GPIO_0_MASK_SET, mask);
1036 static INLINE
void gpio_port_0_int_mask_rise(
int pin)
1038 uint32_t reg = (1 << (pin + GPIO_PORT_0_INT_RISE_EDGE_SHIFT));
1039 WR_WORD(GLOBAL_REG_INTR_GPIO_0_MASK_SET, reg);
1042 static INLINE
void gpio_port_0_int_mask_fall(
int pin)
1044 uint32_t reg = (1 << (pin + GPIO_PORT_0_INT_FALL_EDGE_SHIFT));
1045 WR_WORD(GLOBAL_REG_INTR_GPIO_0_MASK_SET, reg);
1048 static INLINE
void gpio_port_0_int_mask_wup(
int pin)
1050 uint32_t reg = (1 << (pin + GPIO_PORT_0_WUP_SHIFT));
1051 WR_WORD(GLOBAL_REG_INTR_GPIO_0_MASK_SET, reg);
1054 static INLINE
void gpio_port_0_int_unmask(uint32_t mask)
1056 WR_WORD(GLOBAL_REG_INTR_GPIO_0_MASK_CLEAR, mask);
1059 static INLINE
void gpio_port_0_int_unmask_rise(
int pin)
1061 uint32_t reg = (1 << (pin + GPIO_PORT_0_INT_RISE_EDGE_SHIFT));
1062 WR_WORD(GLOBAL_REG_INTR_GPIO_0_MASK_CLEAR, reg);
1065 static INLINE
void gpio_port_0_int_unmask_fall(
int pin)
1067 uint32_t reg = (1 << (pin + GPIO_PORT_0_INT_FALL_EDGE_SHIFT));
1068 WR_WORD(GLOBAL_REG_INTR_GPIO_0_MASK_CLEAR, reg);
1071 static INLINE
void gpio_port_0_int_unmask_wup(
int pin)
1073 uint32_t reg = (1 << (pin + GPIO_PORT_0_WUP_SHIFT));
1074 WR_WORD(GLOBAL_REG_INTR_GPIO_0_MASK_CLEAR, reg);
1077 static INLINE uint32_t gpio_port_1_int_status(
void)
1079 return (RD_WORD(GLOBAL_REG_INTR_GPIO_1_STATUS));
1082 static INLINE
void gpio_port_1_int_clear(uint32_t pin)
1084 uint32_t reg = (1 << pin) | (1 << (pin + GPIO_PORT_1_INT_FALL_EDGE_SHIFT)) | (1 << (pin + GPIO_PORT_1_WUP_SHIFT));
1085 WR_WORD(GLOBAL_REG_INTR_GPIO_1_CLEAR, reg);
1088 static INLINE
void gpio_port_1_int_clear_all(
void)
1090 WR_WORD(GLOBAL_REG_INTR_GPIO_1_CLEAR, GLOBAL_REG_INTR_GPIO_1_CLEAR_IRQ);
1093 static INLINE uint32_t gpio_port_1_int_mask_status(
void)
1095 return (RD_WORD(GLOBAL_REG_INTR_GPIO_1_MASK_STATUS));
1098 static INLINE
void gpio_port_1_int_mask_all(
void)
1100 WR_WORD(GLOBAL_REG_INTR_GPIO_1_MASK_SET, GLOBAL_REG_INTR_GPIO_1_MASK_SET_IRQ);
1103 static INLINE
void gpio_port_1_int_mask(uint32_t mask)
1105 WR_WORD(GLOBAL_REG_INTR_GPIO_1_MASK_SET, mask);
1108 static INLINE
void gpio_port_1_int_mask_rise(
int pin)
1110 uint32_t reg = (1 << (pin + GPIO_PORT_1_INT_RISE_EDGE_SHIFT));
1111 WR_WORD(GLOBAL_REG_INTR_GPIO_1_MASK_SET, reg);
1114 static INLINE
void gpio_port_1_int_mask_fall(
int pin)
1116 uint32_t reg = (1 << (pin + GPIO_PORT_1_INT_FALL_EDGE_SHIFT));
1117 WR_WORD(GLOBAL_REG_INTR_GPIO_1_MASK_SET, reg);
1120 static INLINE
void gpio_port_1_int_mask_wup(
int pin)
1122 uint32_t reg = (1 << (pin + GPIO_PORT_1_WUP_SHIFT));
1123 WR_WORD(GLOBAL_REG_INTR_GPIO_1_MASK_SET, reg);
1126 static INLINE
void gpio_port_1_int_unmask(uint32_t mask)
1128 WR_WORD(GLOBAL_REG_INTR_GPIO_1_MASK_CLEAR, mask);
1131 static INLINE
void gpio_port_1_int_unmask_rise(
int pin)
1133 uint32_t reg = (1 << (pin + GPIO_PORT_1_INT_RISE_EDGE_SHIFT));
1134 WR_WORD(GLOBAL_REG_INTR_GPIO_1_MASK_CLEAR, reg);
1137 static INLINE
void gpio_port_1_int_unmask_fall(
int pin)
1139 uint32_t reg = (1 << (pin + GPIO_PORT_1_INT_FALL_EDGE_SHIFT));
1140 WR_WORD(GLOBAL_REG_INTR_GPIO_1_MASK_CLEAR, reg);
1143 static INLINE
void gpio_port_1_int_unmask_wup(
int pin)
1145 uint32_t reg = (1 << (pin + GPIO_PORT_1_WUP_SHIFT));
1146 WR_WORD(GLOBAL_REG_INTR_GPIO_1_MASK_CLEAR, reg);
1149 static INLINE uint32_t gpio_port_2_int_status(
void)
1151 return (RD_WORD(GLOBAL_REG_INTR_GPIO_2_STATUS));
1154 static INLINE
void gpio_port_2_int_clear(uint32_t pin)
1156 uint32_t reg = (1 << pin) | (1 << (pin + GPIO_PORT_2_INT_FALL_EDGE_SHIFT)) | (1 << (pin + GPIO_PORT_2_WUP_SHIFT));
1157 WR_WORD(GLOBAL_REG_INTR_GPIO_2_CLEAR, reg);
1160 static INLINE
void gpio_port_2_int_clear_all(
void)
1162 WR_WORD(GLOBAL_REG_INTR_GPIO_2_CLEAR, GLOBAL_REG_INTR_GPIO_2_CLEAR_IRQ);
1165 static INLINE uint32_t gpio_port_2_int_mask_status(
void)
1167 return (RD_WORD(GLOBAL_REG_INTR_GPIO_2_MASK_STATUS));
1170 static INLINE
void gpio_port_2_int_mask_all(
void)
1172 WR_WORD(GLOBAL_REG_INTR_GPIO_2_MASK_SET, GLOBAL_REG_INTR_GPIO_2_MASK_SET_IRQ);
1175 static INLINE
void gpio_port_2_int_mask(uint32_t mask)
1177 WR_WORD(GLOBAL_REG_INTR_GPIO_2_MASK_SET, mask);
1180 static INLINE
void gpio_port_2_int_mask_rise(
int pin)
1182 uint32_t reg = (1 << (pin + GPIO_PORT_2_INT_RISE_EDGE_SHIFT));
1183 WR_WORD(GLOBAL_REG_INTR_GPIO_2_MASK_SET, reg);
1186 static INLINE
void gpio_port_2_int_mask_fall(
int pin)
1188 uint32_t reg = (1 << (pin + GPIO_PORT_2_INT_FALL_EDGE_SHIFT));
1189 WR_WORD(GLOBAL_REG_INTR_GPIO_2_MASK_SET, reg);
1192 static INLINE
void gpio_port_2_int_mask_wup(
int pin)
1194 uint32_t reg = (1 << (pin + GPIO_PORT_2_WUP_SHIFT));
1195 WR_WORD(GLOBAL_REG_INTR_GPIO_2_MASK_SET, reg);
1198 static INLINE
void gpio_port_2_int_unmask(uint32_t mask)
1200 WR_WORD(GLOBAL_REG_INTR_GPIO_2_MASK_CLEAR, mask);
1203 static INLINE
void gpio_port_2_int_unmask_rise(
int pin)
1205 uint32_t reg = (1 << (pin + GPIO_PORT_2_INT_RISE_EDGE_SHIFT));
1206 WR_WORD(GLOBAL_REG_INTR_GPIO_2_MASK_CLEAR, reg);
1209 static INLINE
void gpio_port_2_int_unmask_fall(
int pin)
1211 uint32_t reg = (1 << (pin + GPIO_PORT_2_INT_FALL_EDGE_SHIFT));
1212 WR_WORD(GLOBAL_REG_INTR_GPIO_2_MASK_CLEAR, reg);
1215 static INLINE
void gpio_port_2_int_unmask_wup(
int pin)
1217 uint32_t reg = (1 << (pin + GPIO_PORT_2_WUP_SHIFT));
1218 WR_WORD(GLOBAL_REG_INTR_GPIO_2_MASK_CLEAR, reg);
1221 static INLINE uint32_t gpio_port_3_int_status(
void)
1223 return (RD_WORD(GLOBAL_REG_INTR_GPIO_3_STATUS));
1226 static INLINE
void gpio_port_3_int_clear(uint32_t pin)
1228 uint32_t reg = (1 << pin) | (1 << (pin + GPIO_PORT_3_INT_FALL_EDGE_SHIFT)) | (1 << (pin + GPIO_PORT_3_WUP_SHIFT));
1229 WR_WORD(GLOBAL_REG_INTR_GPIO_3_CLEAR, reg);
1232 static INLINE
void gpio_port_3_int_clear_all(
void)
1234 WR_WORD(GLOBAL_REG_INTR_GPIO_3_CLEAR, GLOBAL_REG_INTR_GPIO_3_CLEAR_IRQ);
1237 static INLINE uint32_t gpio_port_3_int_mask_status(
void)
1239 return (RD_WORD(GLOBAL_REG_INTR_GPIO_3_MASK_STATUS));
1242 static INLINE
void gpio_port_3_int_mask_all(
void)
1244 WR_WORD(GLOBAL_REG_INTR_GPIO_3_MASK_SET, GLOBAL_REG_INTR_GPIO_3_MASK_SET_IRQ);
1247 static INLINE
void gpio_port_3_int_mask(uint32_t mask)
1249 WR_WORD(GLOBAL_REG_INTR_GPIO_3_MASK_SET, mask);
1252 static INLINE
void gpio_port_3_int_mask_rise(
int pin)
1254 uint32_t reg = (1 << (pin + GPIO_PORT_3_INT_RISE_EDGE_SHIFT));
1255 WR_WORD(GLOBAL_REG_INTR_GPIO_3_MASK_SET, reg);
1258 static INLINE
void gpio_port_3_int_mask_fall(
int pin)
1260 uint32_t reg = (1 << (pin + GPIO_PORT_3_INT_FALL_EDGE_SHIFT));
1261 WR_WORD(GLOBAL_REG_INTR_GPIO_3_MASK_SET, reg);
1264 static INLINE
void gpio_port_3_int_mask_wup(
int pin)
1266 uint32_t reg = (1 << (pin + GPIO_PORT_3_WUP_SHIFT));
1267 WR_WORD(GLOBAL_REG_INTR_GPIO_3_MASK_SET, reg);
1270 static INLINE
void gpio_port_3_int_unmask(uint32_t mask)
1272 WR_WORD(GLOBAL_REG_INTR_GPIO_3_MASK_CLEAR, mask);
1275 static INLINE
void gpio_port_3_int_unmask_rise(
int pin)
1277 uint32_t reg = (1 << (pin + GPIO_PORT_3_INT_RISE_EDGE_SHIFT));
1278 WR_WORD(GLOBAL_REG_INTR_GPIO_3_MASK_CLEAR, reg);
1281 static INLINE
void gpio_port_3_int_unmask_fall(
int pin)
1283 uint32_t reg = (1 << (pin + GPIO_PORT_3_INT_FALL_EDGE_SHIFT));
1284 WR_WORD(GLOBAL_REG_INTR_GPIO_3_MASK_CLEAR, reg);
1287 static INLINE
void gpio_port_3_int_unmask_wup(
int pin)
1289 uint32_t reg = (1 << (pin + GPIO_PORT_3_WUP_SHIFT));
1290 WR_WORD(GLOBAL_REG_INTR_GPIO_3_MASK_CLEAR, reg);
1293 static INLINE uint32_t gpio_port_4_int_status(
void)
1295 return (RD_WORD(GLOBAL_REG_INTR_GPIO_4_STATUS));
1298 static INLINE
void gpio_port_4_int_clear(uint32_t pin)
1300 uint32_t reg = (1 << pin) | (1 << (pin + GPIO_PORT_4_INT_FALL_EDGE_SHIFT)) | (1 << (pin + GPIO_PORT_4_WUP_SHIFT));
1301 WR_WORD(GLOBAL_REG_INTR_GPIO_4_CLEAR, reg);
1304 static INLINE
void gpio_port_4_int_clear_all(
void)
1306 WR_WORD(GLOBAL_REG_INTR_GPIO_4_CLEAR, GLOBAL_REG_INTR_GPIO_4_CLEAR_IRQ);
1309 static INLINE uint32_t gpio_port_4_int_mask_status(
void)
1311 return (RD_WORD(GLOBAL_REG_INTR_GPIO_4_MASK_STATUS));
1314 static INLINE
void gpio_port_4_int_mask_all(
void)
1316 WR_WORD(GLOBAL_REG_INTR_GPIO_4_MASK_SET, GLOBAL_REG_INTR_GPIO_4_MASK_SET_IRQ);
1319 static INLINE
void gpio_port_4_int_mask(uint32_t mask)
1321 WR_WORD(GLOBAL_REG_INTR_GPIO_4_MASK_SET, mask);
1324 static INLINE
void gpio_port_4_int_mask_rise(
int pin)
1326 uint32_t reg = (1 << (pin + GPIO_PORT_4_INT_RISE_EDGE_SHIFT));
1327 WR_WORD(GLOBAL_REG_INTR_GPIO_4_MASK_SET, reg);
1330 static INLINE
void gpio_port_4_int_mask_fall(
int pin)
1332 uint32_t reg = (1 << (pin + GPIO_PORT_4_INT_FALL_EDGE_SHIFT));
1333 WR_WORD(GLOBAL_REG_INTR_GPIO_4_MASK_SET, reg);
1336 static INLINE
void gpio_port_4_int_mask_wup(
int pin)
1338 uint32_t reg = (1 << (pin + GPIO_PORT_4_WUP_SHIFT));
1339 WR_WORD(GLOBAL_REG_INTR_GPIO_4_MASK_SET, reg);
1342 static INLINE
void gpio_port_4_int_unmask(uint32_t mask)
1344 WR_WORD(GLOBAL_REG_INTR_GPIO_4_MASK_CLEAR, mask);
1347 static INLINE
void gpio_port_4_int_unmask_rise(
int pin)
1349 uint32_t reg = (1 << (pin + GPIO_PORT_4_INT_RISE_EDGE_SHIFT));
1350 WR_WORD(GLOBAL_REG_INTR_GPIO_4_MASK_CLEAR, reg);
1353 static INLINE
void gpio_port_4_int_unmask_fall(
int pin)
1355 uint32_t reg = (1 << (pin + GPIO_PORT_4_INT_FALL_EDGE_SHIFT));
1356 WR_WORD(GLOBAL_REG_INTR_GPIO_4_MASK_CLEAR, reg);
1359 static INLINE
void gpio_port_4_int_unmask_wup(
int pin)
1361 uint32_t reg = (1 << (pin + GPIO_PORT_4_WUP_SHIFT));
1362 WR_WORD(GLOBAL_REG_INTR_GPIO_4_MASK_CLEAR, reg);
1365 #define INTR_GPIO_STATUS_OFFSET 0x0 1366 #define INTR_GPIO_MASK_STATUS_OFFSET 0x4 1367 #define INTR_GPIO_CLEAR_OFFSET 0x8 1368 #define INTR_GPIO_SET_OFFSET 0xC 1369 #define INTR_GPIO_MASK_SET_OFFSET 0x10 1370 #define INTR_GPIO_MASK_CLEAR_OFFSET 0x14 1372 static INLINE uint32_t gpio_int_status(uint32_t addr)
1374 return RD_WORD((addr + INTR_GPIO_STATUS_OFFSET));
1377 static INLINE uint32_t gpio_int_mask_status(uint32_t addr)
1379 return RD_WORD((addr + INTR_GPIO_MASK_STATUS_OFFSET));
1382 static INLINE
void gpio_int_clear_all(uint32_t addr, uint32_t status)
1384 WR_WORD((addr + INTR_GPIO_CLEAR_OFFSET), status);
1387 static INLINE
void gpio_int_clear(uint32_t addr, uint32_t npin, uint32_t pin)
1389 WR_WORD((addr + INTR_GPIO_CLEAR_OFFSET), ((1 << pin)|(1 << (npin + pin))));
1392 static INLINE
void gpio_int_mask_all(uint32_t addr, uint32_t mask)
1394 WR_WORD((addr + INTR_GPIO_MASK_SET_OFFSET), mask);
1397 static INLINE
void gpio_int_mask(uint32_t addr, uint32_t pin)
1399 WR_WORD((addr + INTR_GPIO_MASK_SET_OFFSET), (1 << pin));
1402 static INLINE
void gpio_int_unmask(uint32_t addr, uint32_t pin)
1404 WR_WORD((addr + INTR_GPIO_MASK_CLEAR_OFFSET), (1 << pin));
1407 static INLINE
void gpio_int_unmask_all(uint32_t addr, uint32_t unmask)
1409 WR_WORD((addr + INTR_GPIO_MASK_CLEAR_OFFSET), unmask);
1412 static INLINE
void gpio_port_0_pad_latch(
int pin,
int latch)
1414 uint32_t reg = RD_WORD(GLOBAL2_REG_GPIO_LE_CTRL);
1417 reg |= (1 << (pin + GLOBAL2_REG_GPIO_LE_CTRL_CTL_GPIO_0_LE_SHIFT));
1419 reg &= ~(1 << (pin + GLOBAL2_REG_GPIO_LE_CTRL_CTL_GPIO_0_LE_SHIFT));
1421 WR_WORD(GLOBAL2_REG_GPIO_LE_CTRL, reg);
1424 static INLINE
void gpio_port_1_pad_latch(
int pin,
int latch)
1426 uint32_t reg = RD_WORD(GLOBAL2_REG_GPIO_LE_CTRL);
1429 reg |= (1 << (pin + GLOBAL2_REG_GPIO_LE_CTRL_CTL_GPIO_1_LE_SHIFT));
1431 reg &= ~(1 << (pin + GLOBAL2_REG_GPIO_LE_CTRL_CTL_GPIO_1_LE_SHIFT));
1433 WR_WORD(GLOBAL2_REG_GPIO_LE_CTRL, reg);
1436 static INLINE
void gpio_port_2_pad_latch(
int pin,
int latch)
1438 uint32_t reg = RD_WORD(GLOBAL2_REG_GPIO_LE_CTRL);
1441 reg |= (1 << (pin + GLOBAL2_REG_GPIO_LE_CTRL_CTL_GPIO_2_LE_SHIFT));
1443 reg &= ~(1 << (pin + GLOBAL2_REG_GPIO_LE_CTRL_CTL_GPIO_2_LE_SHIFT));
1445 WR_WORD(GLOBAL2_REG_GPIO_LE_CTRL, reg);
1448 static INLINE
void gpio_port_3_pad_latch(
int pin,
int latch)
1450 uint32_t reg = RD_WORD(GLOBAL2_REG_GPIO_LE_CTRL_2);
1453 reg |= (1 << (pin + GLOBAL2_REG_GPIO_LE_CTRL_2_CTL_GPIO_3_LE_SHIFT));
1455 reg &= ~(1 << (pin + GLOBAL2_REG_GPIO_LE_CTRL_2_CTL_GPIO_3_LE_SHIFT));
1457 WR_WORD(GLOBAL2_REG_GPIO_LE_CTRL_2, reg);
1460 static INLINE
void gpio_port_4_pad_latch(
int pin,
int latch)
1462 uint32_t reg = RD_WORD(GLOBAL2_REG_GPIO_LE_CTRL_2);
1465 reg |= (1 << (pin + GLOBAL2_REG_GPIO_LE_CTRL_2_CTL_GPIO_4_LE_SHIFT));
1467 reg &= ~(1 << (pin + GLOBAL2_REG_GPIO_LE_CTRL_2_CTL_GPIO_4_LE_SHIFT));
1469 WR_WORD(GLOBAL2_REG_GPIO_LE_CTRL_2, reg);
1472 static INLINE
void gpio_pad_latch(
int port,
int pin,
int latch)
1478 if (port == GPIO_PORT_0) {
1479 addr = GLOBAL2_REG_GPIO_LE_CTRL;
1480 }
else if (port == GPIO_PORT_1) {
1481 addr = GLOBAL2_REG_GPIO_LE_CTRL;
1482 shift = GLOBAL2_REG_GPIO_LE_CTRL_CTL_GPIO_1_LE_SHIFT;
1483 }
else if (port == GPIO_PORT_2) {
1484 addr = GLOBAL2_REG_GPIO_LE_CTRL;
1485 shift = GLOBAL2_REG_GPIO_LE_CTRL_CTL_GPIO_2_LE_SHIFT;
1486 }
else if (port == GPIO_PORT_3) {
1487 addr = GLOBAL2_REG_GPIO_LE_CTRL_2;
1488 shift = GLOBAL2_REG_GPIO_LE_CTRL_2_CTL_GPIO_3_LE_SHIFT;
1490 addr = GLOBAL2_REG_GPIO_LE_CTRL_2;
1491 shift = GLOBAL2_REG_GPIO_LE_CTRL_2_CTL_GPIO_4_LE_SHIFT;
1494 reg = RD_WORD(addr);
1496 reg |= (1 << (shift + pin));
1498 reg &= ~(1 << (shift + pin));
1503 static INLINE
int gpio_pad_latch_status(
int port,
int pin)
1508 if (port == GPIO_PORT_0) {
1509 addr = GLOBAL2_REG_GPIO_LE_STS;
1510 }
else if (port == GPIO_PORT_1) {
1511 addr = GLOBAL2_REG_GPIO_LE_STS;
1512 shift = GLOBAL2_REG_GPIO_LE_STS_STS_GPIO_1_LE_SHIFT;
1513 }
else if (port == GPIO_PORT_2) {
1514 addr = GLOBAL2_REG_GPIO_LE_STS;
1515 shift = GLOBAL2_REG_GPIO_LE_STS_STS_GPIO_2_LE_SHIFT;
1516 }
else if (port == GPIO_PORT_3) {
1517 addr = GLOBAL2_REG_GPIO_LE_STS_2;
1518 shift = GLOBAL2_REG_GPIO_LE_STS_2_STS_GPIO_3_LE_SHIFT;
1520 addr = GLOBAL2_REG_GPIO_LE_STS_2;
1521 shift = GLOBAL2_REG_GPIO_LE_STS_2_STS_GPIO_4_LE_SHIFT;
1524 return ((RD_WORD(addr) >> (shift + pin)) & 1);
1527 static INLINE
void gpio_port_0_pad_maskb(
int pin,
int en)
1529 uint32_t reg = RD_WORD(GLOBAL2_REG_GPIO_MASKB_CTRL);
1532 reg |= (1 << (pin + GLOBAL2_REG_GPIO_MASKB_CTRL_CTL_GPIO_0_MASKB_SHIFT));
1534 reg &= ~(1 << (pin + GLOBAL2_REG_GPIO_MASKB_CTRL_CTL_GPIO_0_MASKB_SHIFT));
1536 WR_WORD(GLOBAL2_REG_GPIO_MASKB_CTRL, reg);
1539 static INLINE
void gpio_port_1_pad_maskb(
int pin,
int en)
1541 uint32_t reg = RD_WORD(GLOBAL2_REG_GPIO_MASKB_CTRL);
1544 reg |= (1 << (pin + GLOBAL2_REG_GPIO_MASKB_CTRL_CTL_GPIO_1_MASKB_SHIFT));
1546 reg &= ~(1 << (pin + GLOBAL2_REG_GPIO_MASKB_CTRL_CTL_GPIO_1_MASKB_SHIFT));
1548 WR_WORD(GLOBAL2_REG_GPIO_MASKB_CTRL, reg);
1551 static INLINE
void gpio_port_2_pad_maskb(
int pin,
int en)
1553 uint32_t reg = RD_WORD(GLOBAL2_REG_GPIO_MASKB_CTRL);
1556 reg |= (1 << (pin + GLOBAL2_REG_GPIO_MASKB_CTRL_CTL_GPIO_2_MASKB_SHIFT));
1558 reg &= ~(1 << (pin + GLOBAL2_REG_GPIO_MASKB_CTRL_CTL_GPIO_2_MASKB_SHIFT));
1560 WR_WORD(GLOBAL2_REG_GPIO_MASKB_CTRL, reg);
1563 static INLINE
void gpio_port_3_pad_maskb(
int pin,
int en)
1565 uint32_t reg = RD_WORD(GLOBAL2_REG_GPIO_MASKB_CTRL_2);
1568 reg |= (1 << (pin + GLOBAL2_REG_GPIO_MASKB_CTRL_2_CTL_GPIO_3_MASKB_SHIFT));
1570 reg &= ~(1 << (pin + GLOBAL2_REG_GPIO_MASKB_CTRL_2_CTL_GPIO_3_MASKB_SHIFT));
1572 WR_WORD(GLOBAL2_REG_GPIO_MASKB_CTRL, reg);
1575 static INLINE
void gpio_port_4_pad_maskb(
int pin,
int en)
1577 uint32_t reg = RD_WORD(GLOBAL2_REG_GPIO_MASKB_CTRL_2);
1580 reg |= (1 << (pin + GLOBAL2_REG_GPIO_MASKB_CTRL_2_CTL_GPIO_4_MASKB_SHIFT));
1582 reg &= ~(1 << (pin + GLOBAL2_REG_GPIO_MASKB_CTRL_2_CTL_GPIO_4_MASKB_SHIFT));
1584 WR_WORD(GLOBAL2_REG_GPIO_MASKB_CTRL, reg);
1587 static INLINE
void gpio_pad_maskb(
int port,
int pin,
int en)
1593 if (port == GPIO_PORT_0) {
1594 addr = GLOBAL2_REG_GPIO_MASKB_CTRL;
1595 }
else if (port == GPIO_PORT_1) {
1596 addr = GLOBAL2_REG_GPIO_MASKB_CTRL;
1597 shift = GLOBAL2_REG_GPIO_MASKB_CTRL_CTL_GPIO_1_MASKB_SHIFT;
1598 }
else if (port == GPIO_PORT_2) {
1599 addr = GLOBAL2_REG_GPIO_MASKB_CTRL;
1600 shift = GLOBAL2_REG_GPIO_MASKB_CTRL_CTL_GPIO_2_MASKB_SHIFT;
1601 }
else if (port == GPIO_PORT_3) {
1602 addr = GLOBAL2_REG_GPIO_MASKB_CTRL_2;
1603 shift = GLOBAL2_REG_GPIO_MASKB_CTRL_2_CTL_GPIO_3_MASKB_SHIFT;
1605 addr = GLOBAL2_REG_GPIO_MASKB_CTRL_2;
1606 shift = GLOBAL2_REG_GPIO_MASKB_CTRL_2_CTL_GPIO_4_MASKB_SHIFT;
1609 reg = RD_WORD(addr);
1611 reg |= (1 << (shift + pin));
1613 reg &= ~(1 << (shift + pin));
1618 static INLINE
int gpio_pad_maskb_status(
int port,
int pin)
1623 if (port == GPIO_PORT_0) {
1624 addr = GLOBAL2_REG_GPIO_MASKB_STS;
1625 }
else if (port == GPIO_PORT_1) {
1626 addr = GLOBAL2_REG_GPIO_MASKB_STS;
1627 shift = GLOBAL2_REG_GPIO_MASKB_STS_STS_GPIO_1_MASKB_SHIFT;
1628 }
else if (port == GPIO_PORT_2) {
1629 addr = GLOBAL2_REG_GPIO_MASKB_STS;
1630 shift = GLOBAL2_REG_GPIO_MASKB_STS_STS_GPIO_2_MASKB_SHIFT;
1631 }
else if (port == GPIO_PORT_3) {
1632 addr = GLOBAL2_REG_GPIO_MASKB_STS_2;
1633 shift = GLOBAL2_REG_GPIO_MASKB_STS_2_STS_GPIO_3_MASKB_SHIFT;
1635 addr = GLOBAL2_REG_GPIO_MASKB_STS_2;
1636 shift = GLOBAL2_REG_GPIO_MASKB_STS_2_STS_GPIO_4_MASKB_SHIFT;
1639 return ((RD_WORD(addr) >> (pin + shift)) & 1);
1642 static INLINE
void gpio_port_0_wup_mask(
int pin,
int mask)
1644 uint32_t reg = RD_WORD(GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL);
1647 reg &= ~(1 << (pin + GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL_CTL_GPIO_0_WAKEUP_MASK_SHIFT));
1649 reg |= (1 << (pin + GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL_CTL_GPIO_0_WAKEUP_MASK_SHIFT));
1651 WR_WORD(GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL, reg);
1654 static INLINE
void gpio_port_1_wup_mask(
int pin,
int mask)
1656 uint32_t reg = RD_WORD(GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL);
1659 reg &= ~(1 << (pin + GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL_CTL_GPIO_1_WAKEUP_MASK_SHIFT));
1661 reg |= (1 << (pin + GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL_CTL_GPIO_1_WAKEUP_MASK_SHIFT));
1663 WR_WORD(GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL, reg);
1666 static INLINE
void gpio_port_2_wup_mask(
int pin,
int mask)
1668 uint32_t reg = RD_WORD(GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL);
1671 reg &= ~(1 << (pin + GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL_CTL_GPIO_2_WAKEUP_MASK_SHIFT));
1673 reg |= (1 << (pin + GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL_CTL_GPIO_2_WAKEUP_MASK_SHIFT));
1675 WR_WORD(GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL, reg);
1678 static INLINE
void gpio_port_3_wup_mask(
int pin,
int mask)
1680 uint32_t reg = RD_WORD(GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL_2);
1683 reg &= ~(1 << (pin + GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL_2_CTL_GPIO_3_WAKEUP_MASK_SHIFT));
1685 reg |= (1 << (pin + GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL_2_CTL_GPIO_3_WAKEUP_MASK_SHIFT));
1687 WR_WORD(GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL_2, reg);
1690 static INLINE
void gpio_port_4_wup_mask(
int pin,
int mask)
1692 uint32_t reg = RD_WORD(GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL_2);
1695 reg &= ~(1 << (pin + GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL_2_CTL_GPIO_4_WAKEUP_MASK_SHIFT));
1697 reg |= (1 << (pin + GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL_2_CTL_GPIO_4_WAKEUP_MASK_SHIFT));
1699 WR_WORD(GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL_2, reg);
1702 static INLINE
void gpio_wup_mask(
int port,
int pin,
int mask)
1708 if (port == GPIO_PORT_0) {
1709 addr = GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL;
1710 }
else if (port == GPIO_PORT_1) {
1711 addr = GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL;
1712 shift = GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL_CTL_GPIO_1_WAKEUP_MASK_SHIFT;
1713 }
else if (port == GPIO_PORT_2) {
1714 addr = GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL;
1715 shift = GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL_CTL_GPIO_2_WAKEUP_MASK_SHIFT;
1716 }
else if (port == GPIO_PORT_3) {
1717 addr = GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL_2;
1718 shift = GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL_2_CTL_GPIO_3_WAKEUP_MASK_SHIFT;
1720 addr = GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL_2;
1721 shift = GLOBAL2_REG_GPIO_WAKEUP_MASK_CTRL_2_CTL_GPIO_4_WAKEUP_MASK_SHIFT;
1724 reg = RD_WORD(addr);
1726 reg &= ~(1 << (shift + pin));
1728 reg |= (1 << (shift + pin));
1733 static INLINE
int gpio_wup_mask_status(
int port,
int pin)
1738 if (port == GPIO_PORT_0) {
1739 addr = GLOBAL2_REG_GPIO_WAKEUP_MASK_STS;
1740 }
else if (port == GPIO_PORT_1) {
1741 addr = GLOBAL2_REG_GPIO_WAKEUP_MASK_STS;
1742 shift = GLOBAL2_REG_GPIO_WAKEUP_MASK_STS_STS_GPIO_1_WAKEUP_MASK_SHIFT;
1743 }
else if (port == GPIO_PORT_2) {
1744 addr = GLOBAL2_REG_GPIO_WAKEUP_MASK_STS;
1745 shift = GLOBAL2_REG_GPIO_WAKEUP_MASK_STS_STS_GPIO_2_WAKEUP_MASK_SHIFT;
1746 }
else if (port == GPIO_PORT_3) {
1747 addr = GLOBAL2_REG_GPIO_WAKEUP_MASK_STS_2;
1748 shift = GLOBAL2_REG_GPIO_WAKEUP_MASK_STS_2_STS_GPIO_3_WAKEUP_MASK_SHIFT;
1750 addr = GLOBAL2_REG_GPIO_WAKEUP_MASK_STS_2;
1751 shift = GLOBAL2_REG_GPIO_WAKEUP_MASK_STS_2_STS_GPIO_4_WAKEUP_MASK_SHIFT;
1754 return ((RD_WORD(addr) >> (shift + pin)) & 1);
1757 static INLINE
void gpio_port_0_wup_pol(
int pin,
int polarity)
1759 uint32_t reg = RD_WORD(GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL);
1762 reg &= ~(1 << (pin + GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL_CTL_GPIO_0_WAKEUP_POLARITY_SHIFT));
1764 reg |= (1 << (pin + GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL_CTL_GPIO_0_WAKEUP_POLARITY_SHIFT));
1766 WR_WORD(GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL, reg);
1769 static INLINE
void gpio_port_1_wup_pol(
int pin,
int polarity)
1771 uint32_t reg = RD_WORD(GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL);
1774 reg &= ~(1 << (pin + GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL_CTL_GPIO_1_WAKEUP_POLARITY_SHIFT));
1776 reg |= (1 << (pin + GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL_CTL_GPIO_1_WAKEUP_POLARITY_SHIFT));
1778 WR_WORD(GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL, reg);
1781 static INLINE
void gpio_port_2_wup_pol(
int pin,
int polarity)
1783 uint32_t reg = RD_WORD(GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL);
1786 reg &= ~(1 << (pin + GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL_CTL_GPIO_2_WAKEUP_POLARITY_SHIFT));
1788 reg |= (1 << (pin + GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL_CTL_GPIO_2_WAKEUP_POLARITY_SHIFT));
1790 WR_WORD(GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL, reg);
1793 static INLINE
void gpio_port_3_wup_pol(
int pin,
int polarity)
1795 uint32_t reg = RD_WORD(GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL_2);
1798 reg &= ~(1 << (pin + GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL_2_CTL_GPIO_3_WAKEUP_POLARITY_SHIFT));
1800 reg |= (1 << (pin + GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL_2_CTL_GPIO_3_WAKEUP_POLARITY_SHIFT));
1802 WR_WORD(GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL_2, reg);
1805 static INLINE
void gpio_port_4_wup_pol(
int pin,
int polarity)
1807 uint32_t reg = RD_WORD(GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL_2);
1810 reg &= ~(1 << (pin + GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL_2_CTL_GPIO_4_WAKEUP_POLARITY_SHIFT));
1812 reg |= (1 << (pin + GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL_2_CTL_GPIO_4_WAKEUP_POLARITY_SHIFT));
1814 WR_WORD(GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL_2, reg);
1817 static INLINE
void gpio_wup_polarity(
int port,
int pin,
int polarity)
1823 if (port == GPIO_PORT_0) {
1824 addr = GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL;
1825 }
else if (port == GPIO_PORT_1) {
1826 addr = GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL;
1827 shift = GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL_CTL_GPIO_1_WAKEUP_POLARITY_SHIFT;
1828 }
else if (port == GPIO_PORT_2) {
1829 addr = GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL;
1830 shift = GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL_CTL_GPIO_2_WAKEUP_POLARITY_SHIFT;
1831 }
else if (port == GPIO_PORT_3) {
1832 addr = GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL_2;
1833 shift = GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL_2_CTL_GPIO_3_WAKEUP_POLARITY_SHIFT;
1835 addr = GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL_2;
1836 shift = GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL_2_CTL_GPIO_4_WAKEUP_POLARITY_SHIFT;
1839 reg = RD_WORD(addr);
1841 reg &= ~(1 << (shift + pin));
1843 reg |= (1 << (shift + pin));
1848 static INLINE
int gpio_wup_polarity_status(
int port,
int pin)
1853 if (port == GPIO_PORT_0) {
1854 addr = GLOBAL2_REG_GPIO_WAKEUP_POLARITY_STS;
1855 }
else if (port == GPIO_PORT_1) {
1856 addr = GLOBAL2_REG_GPIO_WAKEUP_POLARITY_STS;
1857 shift = GLOBAL2_REG_GPIO_WAKEUP_POLARITY_STS_STS_GPIO_1_WAKEUP_POLARITY_SHIFT;
1858 }
else if (port == GPIO_PORT_2) {
1859 addr = GLOBAL2_REG_GPIO_WAKEUP_POLARITY_STS;
1860 shift = GLOBAL2_REG_GPIO_WAKEUP_POLARITY_STS_STS_GPIO_2_WAKEUP_POLARITY_SHIFT;
1861 }
else if (port == GPIO_PORT_3) {
1862 addr = GLOBAL2_REG_GPIO_WAKEUP_POLARITY_STS_2;
1863 shift = GLOBAL2_REG_GPIO_WAKEUP_POLARITY_STS_2_STS_GPIO_3_WAKEUP_POLARITY_SHIFT;
1865 addr = GLOBAL2_REG_GPIO_WAKEUP_POLARITY_STS_2;
1866 shift = GLOBAL2_REG_GPIO_WAKEUP_POLARITY_STS_2_STS_GPIO_4_WAKEUP_POLARITY_SHIFT;
1869 return ((RD_WORD(addr) >> (shift + pin)) & 1);
1873 static INLINE
void gpio_edge_clear(
int port,
int pin)
1878 if (port == GPIO_PORT_0) {
1879 addr = GLOBAL2_REG_GPIO_EDGE_MANUAL_CLR;
1880 }
else if (port == GPIO_PORT_1) {
1881 addr = GLOBAL2_REG_GPIO_EDGE_MANUAL_CLR;
1882 shift = GLOBAL2_REG_GPIO_EDGE_MANUAL_CLR_CTL_GPIO_1_EDGE_MANUAL_CLR_SHIFT;
1883 }
else if (port == GPIO_PORT_2) {
1884 addr = GLOBAL2_REG_GPIO_EDGE_MANUAL_CLR;
1885 shift = GLOBAL2_REG_GPIO_EDGE_MANUAL_CLR_CTL_GPIO_2_EDGE_MANUAL_CLR_SHIFT;
1886 }
else if (port == GPIO_PORT_3) {
1887 addr = GLOBAL2_REG_GPIO_EDGE_MANUAL_CLR_2;
1888 shift = GLOBAL2_REG_GPIO_EDGE_MANUAL_CLR_2_CTL_GPIO_3_EDGE_MANUAL_CLR_SHIFT;
1890 addr = GLOBAL2_REG_GPIO_EDGE_MANUAL_CLR_2;
1891 shift = GLOBAL2_REG_GPIO_EDGE_MANUAL_CLR_2_CTL_GPIO_4_EDGE_MANUAL_CLR_SHIFT;
1894 WR_WORD(addr, (1 << (pin + shift)));
1897 static INLINE
int gpio_edge_clear_status(
int port,
int pin)
1902 if (port == GPIO_PORT_0) {
1903 addr = GLOBAL2_REG_GPIO_EDGE_MANUAL_CLR_STS;
1904 }
else if (port == GPIO_PORT_1) {
1905 addr = GLOBAL2_REG_GPIO_EDGE_MANUAL_CLR_STS;
1906 shift = GLOBAL2_REG_GPIO_EDGE_MANUAL_CLR_STS_STS_GPIO_1_EDGE_MANUAL_CLR_SHIFT;
1907 }
else if (port == GPIO_PORT_2) {
1908 addr = GLOBAL2_REG_GPIO_EDGE_MANUAL_CLR_STS;
1909 shift = GLOBAL2_REG_GPIO_EDGE_MANUAL_CLR_STS_STS_GPIO_2_EDGE_MANUAL_CLR_SHIFT;
1910 }
else if (port == GPIO_PORT_3) {
1911 addr = GLOBAL2_REG_GPIO_EDGE_MANUAL_CLR_STS_2;
1912 shift = GLOBAL2_REG_GPIO_EDGE_MANUAL_CLR_STS_2_STS_GPIO_3_EDGE_MANUAL_CLR_SHIFT;
1914 addr = GLOBAL2_REG_GPIO_EDGE_MANUAL_CLR_STS_2;
1915 shift = GLOBAL2_REG_GPIO_EDGE_MANUAL_CLR_STS_2_STS_GPIO_4_EDGE_MANUAL_CLR_SHIFT;
1918 return ((RD_WORD(addr) >> (shift + pin)) & 1);
1921 static INLINE
void gpio_aon_edge_rise(
int port,
int pin,
int en)
1927 if (port == GPIO_PORT_0) {
1928 addr = AON_REG_GPIO_EDGE_RISING_EN;
1929 }
else if (port == GPIO_PORT_1) {
1930 addr = AON_REG_GPIO_EDGE_RISING_EN;
1932 }
else if (port == GPIO_PORT_2) {
1933 addr = AON_REG_GPIO_EDGE_RISING_EN;
1935 }
else if (port == GPIO_PORT_3) {
1936 addr = AON_REG_GPIO_EDGE_RISING_EN_2;
1939 addr = AON_REG_GPIO_EDGE_RISING_EN_2;
1943 reg = RD_WORD(addr);
1945 reg |= 1 << (pin + shift);
1947 reg &= ~(1 << (pin + shift));
1951 static INLINE
void gpio_aon_edge_fall(
int port,
int pin,
int en)
1957 if (port == GPIO_PORT_0) {
1958 addr = AON_REG_GPIO_EDGE_FALLING_EN;
1959 }
else if (port == GPIO_PORT_1) {
1960 addr = AON_REG_GPIO_EDGE_FALLING_EN;
1962 }
else if (port == GPIO_PORT_2) {
1963 addr = AON_REG_GPIO_EDGE_FALLING_EN;
1965 }
else if (port == GPIO_PORT_3) {
1966 addr = AON_REG_GPIO_EDGE_FALLING_EN_2;
1969 addr = AON_REG_GPIO_EDGE_FALLING_EN_2;
1973 reg = RD_WORD(addr);
1975 reg |= 1 << (pin + shift);
1977 reg &= ~(1 << (pin + shift));
1981 static INLINE
void gpio_aon_edge_clear_on_sleep(
int port,
int pin,
int en)
1987 if (port == GPIO_PORT_0) {
1988 addr = AON_REG_GPIO_EDGE_AUTO_CLEAR_ON_SLEEP;
1989 }
else if (port == GPIO_PORT_1) {
1990 addr = AON_REG_GPIO_EDGE_AUTO_CLEAR_ON_SLEEP;
1992 }
else if (port == GPIO_PORT_2) {
1993 addr = AON_REG_GPIO_EDGE_AUTO_CLEAR_ON_SLEEP;
1995 }
else if (port == GPIO_PORT_3) {
1996 addr = AON_REG_GPIO_EDGE_AUTO_CLEAR_ON_SLEEP_2;
1999 addr = AON_REG_GPIO_EDGE_AUTO_CLEAR_ON_SLEEP_2;
2003 reg = RD_WORD(addr);
2005 reg |= 1 << (pin + shift);
2007 reg &= ~(1 << (pin + shift));
2011 static INLINE
void gpio_aon_edge_detect_in_sleep(
int port,
int pin,
int en)
2017 if (port == GPIO_PORT_0) {
2018 addr = AON_REG_GPIO_EDGE_DETECT_SLEEP_ONLY;
2019 }
else if (port == GPIO_PORT_1) {
2020 addr = AON_REG_GPIO_EDGE_DETECT_SLEEP_ONLY;
2022 }
else if (port == GPIO_PORT_2) {
2023 addr = AON_REG_GPIO_EDGE_DETECT_SLEEP_ONLY;
2025 }
else if (port == GPIO_PORT_3) {
2026 addr = AON_REG_GPIO_EDGE_DETECT_SLEEP_ONLY_2;
2029 addr = AON_REG_GPIO_EDGE_DETECT_SLEEP_ONLY_2;
2033 reg = RD_WORD(addr);
2035 reg |= 1 << (pin + shift);
2037 reg &= ~(1 << (pin + shift));
2041 static INLINE
void gpio_aon_port_0_sel(uint32_t pin,
int en)
2043 uint32_t reg = RD_WORD(AON_REG_GPIO_01_AON_SEL);
2049 WR_WORD(AON_REG_GPIO_01_AON_SEL, reg);
2052 static INLINE
void gpio_aon_port_1_sel(uint32_t pin,
int en)
2054 uint32_t reg = RD_WORD(AON_REG_GPIO_01_AON_SEL);
2056 reg |= (1 << (pin + 16));
2058 reg &= ~(1 << (pin + 16));
2060 WR_WORD(AON_REG_GPIO_01_AON_SEL, reg);
2063 static INLINE
void gpio_aon_port_3_sel(uint32_t pin,
int en)
2065 uint32_t reg = RD_WORD(AON_REG_GPIO_3_AON_SEL);
2071 WR_WORD(AON_REG_GPIO_3_AON_SEL, reg);
2074 static INLINE
void gpio_aon_port_4_sel(uint32_t pin,
int en)
2076 uint32_t reg = RD_WORD(AON_REG_GPIO_3_AON_SEL);
2078 reg |= (1 << (pin + 8));
2080 reg &= ~(1 << (pin + 8));
2082 WR_WORD(AON_REG_GPIO_3_AON_SEL, reg);
2085 static INLINE
void gpio_aon_port_0_output_sel(uint32_t pin,
int mux)
2087 uint32_t addr = AON_REG_GPIO_01_AON_OUTPUT_SEL;
2092 addr = AON_REG_GPIO_01_AON_OUTPUT_SEL_2;
2095 reg = RD_WORD(addr);
2096 reg &= ~(0x7 << (pin << 2));
2097 reg |= ((mux & 0x7) << (pin << 2));
2101 static INLINE
void gpio_aon_port_1_output_sel(uint32_t pin,
int mux)
2103 uint32_t addr = AON_REG_GPIO_01_AON_OUTPUT_SEL_2;
2108 addr = AON_REG_GPIO_13_AON_OUTPUT_SEL;
2113 reg = RD_WORD(addr);
2114 reg &= ~(0x7 << (pin << 2));
2115 reg |= ((mux & 0x7) << (pin << 2));
2119 static INLINE
void gpio_aon_port_3_output_sel(uint32_t pin,
int mux)
2121 uint32_t addr = AON_REG_GPIO_13_AON_OUTPUT_SEL;
2126 addr = AON_REG_GPIO_3_AON_OUTPUT_SEL;
2131 reg = RD_WORD(addr);
2132 reg &= ~(0x7 << (pin << 2));
2133 reg |= ((mux & 0x7) << (pin << 2));
2137 static INLINE
void gpio_aon_port_4_output_sel(uint32_t pin,
int mux)
2139 uint32_t addr = AON_REG_GPIO_3_AON_OUTPUT_SEL;
2143 reg = RD_WORD(addr);
2144 reg &= ~(0x7 << (pin << 2));
2145 reg |= ((mux & 0x7) << (pin << 2));
2150 static INLINE
void gpio_aon_wup_polarity(
int port,
int pin,
int pol)
2152 uint32_t reg = RD_WORD(GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL);
2157 }
else if (port == 1) {
2159 }
else if (port == 2) {
2171 reg &= ~(1 << shift);
2173 reg |= (1 << shift);
2176 WR_WORD(GLOBAL2_REG_GPIO_WAKEUP_POLARITY_CTRL, reg);
2179 static INLINE
void gpio_aon_edge_reset_pd1_clk(
int en)
2181 uint32_t reg = RD_WORD(AON_REG_GPIO_EDGE_FOR_PD1_RST_CTRL_0);
2183 reg |= AON_REG_GPIO_EDGE_FOR_PD1_RST_CTRL_0_CTL_GPIO_EDGE_FOR_PD1_RST_CLK_EN;
2185 reg &= ~AON_REG_GPIO_EDGE_FOR_PD1_RST_CTRL_0_CTL_GPIO_EDGE_FOR_PD1_RST_CLK_EN;
2187 WR_WORD(AON_REG_GPIO_EDGE_FOR_PD1_RST_CTRL_0, reg);
2190 static INLINE
void gpio_aon_edge_reset_pd1_enable(
int idx)
2192 uint32_t addr = AON_REG_GPIO_EDGE_FOR_PD1_RST_CTRL_0 + idx*4;
2193 uint32_t reg = RD_WORD(addr);
2194 reg |= AON_REG_GPIO_EDGE_FOR_PD1_RST_CTRL_0_CTL_GPIO_EDGE_FOR_PD1_RST_EN_0;
2198 static INLINE
void gpio_aon_edge_reset_pd1_disable(
int idx)
2200 uint32_t addr = AON_REG_GPIO_EDGE_FOR_PD1_RST_CTRL_0 + idx*4;
2201 uint32_t reg = RD_WORD(addr);
2202 reg &= ~AON_REG_GPIO_EDGE_FOR_PD1_RST_CTRL_0_CTL_GPIO_EDGE_FOR_PD1_RST_EN_0;
2206 static INLINE
void gpio_aon_edge_reset_pd1(
int idx,
int sidx,
int fall,
int deb)
2208 uint32_t addr = AON_REG_GPIO_EDGE_FOR_PD1_RST_CTRL_0 + idx*4;
2209 uint32_t reg = RD_WORD(addr);
2211 reg &= ~AON_REG_GPIO_EDGE_FOR_PD1_RST_CTRL_0_CTL_GPIO_EDGE_FOR_PD1_RST_SEL_0;
2212 reg |= (sidx & AON_REG_GPIO_EDGE_FOR_PD1_RST_CTRL_0_CTL_GPIO_EDGE_FOR_PD1_RST_SEL_0_MASK) << AON_REG_GPIO_EDGE_FOR_PD1_RST_CTRL_0_CTL_GPIO_EDGE_FOR_PD1_RST_SEL_0_SHIFT;
2214 reg |= AON_REG_GPIO_EDGE_FOR_PD1_RST_CTRL_0_CTL_GPIO_EDGE_FOR_PD1_RST_EDGE_SEL_0;
2215 reg &= ~AON_REG_GPIO_EDGE_FOR_PD1_RST_CTRL_0_CTL_GPIO_EDGE_FOR_PD1_RST_DEB_LMT_0;
2216 reg |= (deb & AON_REG_GPIO_EDGE_FOR_PD1_RST_CTRL_0_CTL_GPIO_EDGE_FOR_PD1_RST_DEB_LMT_0_MASK) << AON_REG_GPIO_EDGE_FOR_PD1_RST_CTRL_0_CTL_GPIO_EDGE_FOR_PD1_RST_DEB_LMT_0_SHIFT;
2220 static INLINE
void gpio_aon_edge_reset_cm4_enable(
void)
2222 uint32_t reg = RD_WORD(AON_REG_GPIO_EDGE_FOR_CM4_RST);
2223 reg |= AON_REG_GPIO_EDGE_FOR_CM4_RST_CTL_GPIO_EDGE_FOR_CM4_RST_EN;
2224 WR_WORD(AON_REG_GPIO_EDGE_FOR_CM4_RST, reg);
2227 static INLINE
void gpio_aon_edge_reset_cm4_disable(
void)
2229 uint32_t reg = RD_WORD(AON_REG_GPIO_EDGE_FOR_CM4_RST);
2230 reg &= ~AON_REG_GPIO_EDGE_FOR_CM4_RST_CTL_GPIO_EDGE_FOR_CM4_RST_EN;
2231 WR_WORD(AON_REG_GPIO_EDGE_FOR_CM4_RST, reg);
2234 static INLINE
void gpio_aon_edge_reset_cm4(
int sidx,
int fall,
int deb,
int sys_rst)
2236 uint32_t reg = RD_WORD(AON_REG_GPIO_EDGE_FOR_CM4_RST);
2237 reg &= ~AON_REG_GPIO_EDGE_FOR_CM4_RST_CTL_GPIO_EDGE_FOR_CM4_RST_SEL;
2238 reg |= (sidx & AON_REG_GPIO_EDGE_FOR_CM4_RST_CTL_GPIO_EDGE_FOR_CM4_RST_SEL_MASK) << AON_REG_GPIO_EDGE_FOR_CM4_RST_CTL_GPIO_EDGE_FOR_CM4_RST_SEL_SHIFT;
2240 reg |= AON_REG_GPIO_EDGE_FOR_CM4_RST_CTL_GPIO_EDGE_FOR_CM4_RST_EDGE_SEL;
2241 reg |= (deb & AON_REG_GPIO_EDGE_FOR_CM4_RST_CTL_GPIO_EDGE_FOR_CM4_RST_DEB_LMT_MASK) << AON_REG_GPIO_EDGE_FOR_CM4_RST_CTL_GPIO_EDGE_FOR_CM4_RST_DEB_LMT_SHIFT;
2243 reg |= AON_REG_GPIO_EDGE_FOR_CM4_RST_CTL_GPIO_EDGE_FOR_CM4_RST_FUNC_SEL;
2244 WR_WORD(AON_REG_GPIO_EDGE_FOR_CM4_RST, reg);
2247 static INLINE
void gpio_aon_edge_det_clk(
int en,
int port)
2249 uint32_t reg = RD_WORD(AON_REG_AON_TIMER_CLK_CTRL);
2252 if (port == GPIO_PORT_0) {
2253 reg |= AON_REG_AON_TIMER_CLK_CTRL_CTL_GPIO_0_EDGE_DETECT_CLK_EN|AON_REG_AON_TIMER_CLK_CTRL_CTL_GPIO_0_EDGE_DETECT_DEB_CLK_EN;
2254 }
else if (port == GPIO_PORT_1) {
2255 reg |= AON_REG_AON_TIMER_CLK_CTRL_CTL_GPIO_1_EDGE_DETECT_CLK_EN|AON_REG_AON_TIMER_CLK_CTRL_CTL_GPIO_1_EDGE_DETECT_DEB_CLK_EN;
2256 }
else if (port == GPIO_PORT_2) {
2257 reg |= AON_REG_AON_TIMER_CLK_CTRL_CTL_GPIO_2_EDGE_DETECT_CLK_EN|AON_REG_AON_TIMER_CLK_CTRL_CTL_GPIO_2_EDGE_DETECT_DEB_CLK_EN;
2258 }
else if (port == GPIO_PORT_3) {
2259 reg |= AON_REG_AON_TIMER_CLK_CTRL_CTL_GPIO_3_EDGE_DETECT_CLK_EN|AON_REG_AON_TIMER_CLK_CTRL_CTL_GPIO_3_EDGE_DETECT_DEB_CLK_EN;
2261 reg |= AON_REG_AON_TIMER_CLK_CTRL_CTL_GPIO_4_EDGE_DETECT_CLK_EN|AON_REG_AON_TIMER_CLK_CTRL_CTL_GPIO_4_EDGE_DETECT_DEB_CLK_EN;
2264 if (port == GPIO_PORT_0) {
2265 reg &= ~(AON_REG_AON_TIMER_CLK_CTRL_CTL_GPIO_0_EDGE_DETECT_CLK_EN|AON_REG_AON_TIMER_CLK_CTRL_CTL_GPIO_0_EDGE_DETECT_DEB_CLK_EN);
2266 }
else if (port == GPIO_PORT_1) {
2267 reg &= ~(AON_REG_AON_TIMER_CLK_CTRL_CTL_GPIO_1_EDGE_DETECT_CLK_EN|AON_REG_AON_TIMER_CLK_CTRL_CTL_GPIO_1_EDGE_DETECT_DEB_CLK_EN);
2268 }
else if (port == GPIO_PORT_2) {
2269 reg &= ~(AON_REG_AON_TIMER_CLK_CTRL_CTL_GPIO_2_EDGE_DETECT_CLK_EN|AON_REG_AON_TIMER_CLK_CTRL_CTL_GPIO_2_EDGE_DETECT_DEB_CLK_EN);
2270 }
else if (port == GPIO_PORT_3) {
2271 reg &= ~(AON_REG_AON_TIMER_CLK_CTRL_CTL_GPIO_3_EDGE_DETECT_CLK_EN|AON_REG_AON_TIMER_CLK_CTRL_CTL_GPIO_3_EDGE_DETECT_DEB_CLK_EN);
2273 reg &= ~(AON_REG_AON_TIMER_CLK_CTRL_CTL_GPIO_4_EDGE_DETECT_CLK_EN|AON_REG_AON_TIMER_CLK_CTRL_CTL_GPIO_4_EDGE_DETECT_DEB_CLK_EN);
2276 WR_WORD(AON_REG_AON_TIMER_CLK_CTRL, reg);
2279 static INLINE
void gpio_qspi_pad_latch(
int latch_mask)
2281 uint32_t reg = RD_WORD(AON_REG_QSPI_LE_MASKB);
2283 reg &= ~(AON_REG_QSPI_LE_MASKB_CTL_QSPI_LE);
2284 reg |= (latch_mask&AON_REG_QSPI_LE_MASKB_CTL_QSPI_LE_MASK)<<AON_REG_QSPI_LE_MASKB_CTL_QSPI_LE_SHIFT;
2287 WR_WORD(AON_REG_QSPI_LE_MASKB, reg);
2289 static INLINE
int gpio_get_cfg_port(uint32_t pin_cfg)
2291 return (pin_cfg >> GPIO_CFG_PORT_SHIFT) & 0xF;
2293 static INLINE
int gpio_get_cfg_pin(uint32_t pin_cfg)
2295 return pin_cfg & 0xF;
2297 static INLINE
int gpio_get_cfg_mux(uint32_t pin_cfg)
2299 return (pin_cfg >> GPIO_CFG_MUX_SHIFT) & 0xF;
2643 int hal_gpio_ext_int_reg(
int port,
int pin,
void *arg,
void (*callback)(
void *,
int,
int,
int));
2757 int hal_gpio_sleep_output_grp_1(
int en,
int port,
int pin,
int mux);
2758 int hal_gpio_sleep_output_grp_2(
int en,
int port,
int pin,
int mux);
2759 int hal_gpio_sleep_output_grp_3(
int en,
int port,
int pin,
int mux);
2797 #endif // HAL_GPIO_H int hal_gpio_ext_int_reg(int port, int pin, void *arg, void(*callback)(void *, int, int, int))
Register external GPIO pin as interrupt.
int hal_gpio_sleep_wup_edge_clear_manual(int port, int pin)
Manually clear wake up GPIO edge.
int hal_gpio_sleep_wup_edge(int port, int pin, int rise, int fall)
Wake up GPIO edge selection.
int hal_gpio_ext_int_unreg(int port, int pin)
Unregister external GPIO pin as interrupt.
int hal_gpio_sleep_wup_mask(int port, int pin, int mask)
Config GPIO pin as wake up pin during deep sleep.
int hal_gpio_pad_pc(int port, int pin, int on)
Config GPIO PAD drive strength.
void hal_gpio_suspend(void)
GPIO pin configuration store before power down.
int hal_gpio_sleep_wup_edge_clear_auto(int port, int pin, int en)
Clear the wake up GPIO edge automatically.
int hal_gpio_ext_int_unmask(int port, int pin, int rise, int fall, int wup)
Unmask GPIO pin interrupt.
int hal_gpio_sleep_pad_latch(int port, int pin, int latch, int manual)
Enable GPIO pad during deep sleep.
int hal_gpio_ext_int_mask(int port, int pin, int rise, int fall, int wup)
Mask GPIO pin interrupt.
void hal_gpio_reset_arm(int en, int port, int pin, int fall, int deb, int sys_rst)
Reset ARM CPU by exteranl GPIO rise/fall edge. : This can reset only cpu but not other HW...
int hal_gpio_sleep_wup_edge_latch(int port, int pin, int en)
Latch the wake up GPIO edge.
int hal_gpio_pad_oe_ie(int port, int pin, int oe, int ie)
Config GPIO PAD as output or input.
int hal_gpio_cfg_wup_edge(int port, int pin, int rise, int fall)
Config GPIO pin to edge wake up.
void hal_gpio_resume(void)
GPIO pin configuration restore after power up.
int hal_gpio_cfg_input(int port, int pin, int pull_cfg)
Config pin to GPIO input.
int hal_gpio_sleep_wup_polarity(int port, int pin, int pol)
Change wake up GPIO pin polarity.
int hal_gpio_cfg_wup_level(int port, int pin, int polarity)
Config GPIO pin to level wake up.
int hal_gpio_output(int port, int pin, int high)
Config GPIO output level.
int hal_gpio_output_status(int port, int pin)
GPIO output status. : The status is only valid if the output is enabled.
int hal_gpio_sleep_wup_edge_detect(int port, int pin, int en)
Detect the wake up GPIO edge.
int hal_gpio_pin_mux(int port, int pin, int mux)
Config GPIO pin mux.
int hal_gpio_cfg_output(int port, int pin)
Config pin to GPIO output.
void hal_gpio_reset_chip(int idx, int en, int port, int pin, int fall, int deb)
Reset chip's PD1 domain by exteranl GPIO rise/fall edge. : This can reset cpu and peripherals but not...
void hal_gpio_pin_dft(uint32_t pin_cfg)
Restore GPIO pin to its default state.
void hal_gpio_init(void)
Initialize GPIO port values.
int hal_gpio_pad_pd_pu(int port, int pin, int pd, int pu)
Config GPIO PAD as pull up or pull down.
void hal_gpio_pin_cfg(uint32_t pin_cfg)
Config GPIO from the user's configuration settings .
int hal_gpio_pin_inv(int port, int pin, int inv)
Config GPIO pin invert.
int hal_gpio_sleep_pad_mask(int port, int pin, int mask)
Enable GPIO pad input during deep sleep.
int hal_gpio_wup_dis(int port, int pin)
Disable GPIO pin wake up.
int hal_gpio_input_status(int port, int pin)
Get GPIO input value.
int hal_gpio_sleep_output_grp_0(int en, int port, int pin, int mux)
Output always on domain (AON) signals thru GPIO mux. : The mux are divided into 4 group (see enum gpi...
int hal_gpio_ext_int_prio(int port, int prio)
Set GPIO interrupt polarity. One port only have one polarity.