Files
Tool/IPL/Customer/Mobis/Gen4_ICUMX_Loader/ip/gpio/gpio.c
2025-12-24 17:21:08 +09:00

103 lines
3.6 KiB
C

/*******************************************************************************
* DESCRIPTION : GPIO Control function
******************************************************************************/
/******************************************************************************
* @file gpio.c
* - Version : 0.01
* @brief
* .
*****************************************************************************/
/******************************************************************************
* History : DD.MM.YYYY Version Description
* : 18.11.2024 0.01 First Release
*****************************************************************************/
#if defined(__CX_IPL__) /* V4H_Cx_Loader */
#include "mem_io.h"
#include "rcar_def.h"
#include "rcar_register.h"
#include "gic.h"
#include "ip_control.h"
#include "timer.h"
#define GP0_8_BASE (BASE_PFC0_ADDR + 0x0180U)
#define GP1_24_BASE (PFC_GP1_BASE + 0x0180U)
#else /* Gen4_ICUMX_Loader */
#include <stdint.h>
#include <types.h>
#include <cpg.h>
#include <pfc.h>
#include <mem_io.h>
#include <micro_wait.h>
#include <rst_register.h>
#define GPIO_BASE (PFC_BASE + PFC_PORT_GRP0)
#define GP0_8_BASE (PFC_BASE + PFC_PORT_GRP0 + 0x0180)
#define GP1_24_BASE (PFC_BASE + PFC_PORT_GRP1 + 0x0180)
#endif
#define GP1_23_BASE GP1_24_BASE
#define GPIO_IOINTSEL 0x00 /* General IO/Interrupt Switching Register */
#define GPIO_INOUTSEL 0x04 /* General Input/Output Switching Register */
#define GPIO_OUTDT 0x08 /* General Output Register */
#define GPIO_INDT 0x0c /* General Input Register */
#define GPIO_INTDT 0x10 /* Interrupt Display Register */
#define GPIO_INTCLR 0x14 /* Interrupt Clear Register */
#define GPIO_INTMSK 0x18 /* Interrupt Mask Register */
#define GPIO_MSKCLR 0x1c /* Interrupt Mask Clear Register */
#define GPIO_POSNEG 0x20 /* Positive/Negative Logic Select Register */
#define GPIO_EDGLEVEL 0x24 /* Edge/level Select Register */
#define GPIO_FILONOFF 0x28 /* Chattering Prevention On/Off Register */
#define GPIO_BOTHEDGE 0x4c /* One Edge/Both Edge Select Register */
#define GPIO_INEN 0x50 /* General Input Enable Register */
#define BIT(nr) (1 << (nr))
void gpio_output_clr_set(uintptr_t regs, int offset, int set)
{
if (set)
mem_bitclrset32(regs + GPIO_OUTDT, 0x0, BIT(offset)); /* set */
else
mem_bitclrset32(regs + GPIO_OUTDT, BIT(offset), 0x0); /* clear */
mem_bitclrset32(regs + GPIO_POSNEG, BIT(offset), 0x0);
mem_bitclrset32(regs + GPIO_INEN, BIT(offset), 0x0);
mem_bitclrset32(regs + GPIO_IOINTSEL, BIT(offset), 0x0);
mem_bitclrset32(regs + GPIO_INOUTSEL, 0x0, BIT(offset)); /* set output */
}
/* End of function gpio_output_clr_set(uintptr_t regs, int offset, int set) */
#if (BOOT_TIME_CHECK != 0)
void gpio_N1307(int set) {
if (set == 2) {
gpio_output_clr_set(GP0_8_BASE, 8, 0);
gpio_output_clr_set(GP0_8_BASE, 8, 1);
micro_wait(10U);
gpio_output_clr_set(GP0_8_BASE, 8, 0);
} else if (set)
gpio_output_clr_set(GP0_8_BASE, 8, 1);
else
gpio_output_clr_set(GP0_8_BASE, 8, 0);
}
void gpio_N1305(int set) {
if (set == 2) {
gpio_output_clr_set(GP1_24_BASE, 24, 0);
micro_wait(10U);
gpio_output_clr_set(GP1_24_BASE, 24, 1);
micro_wait(10U);
// gpio_output_clr_set(GP1_24_BASE, 24, 0);
} else if (set)
gpio_output_clr_set(GP1_24_BASE, 24, 1);
else
gpio_output_clr_set(GP1_24_BASE, 24, 0);
}
#endif
void gpio_V4H_SERDES_1V8_en(int set) {
if (set) {
gpio_output_clr_set(GP1_23_BASE, 23, 1);
} else {
gpio_output_clr_set(GP1_23_BASE, 23, 0);
}
}