修改源码格式

This commit is contained in:
aixiao 2023-11-30 12:50:07 +08:00
parent d6e6b3b2d2
commit e95a874564
2 changed files with 1839 additions and 1911 deletions

View File

@ -25,8 +25,7 @@
#ifdef CONFIG_ORANGEPI
#ifdef CONFIG_ORANGEPI_2G_IOT
int pinToGpioOrangePi[64] =
{
int pinToGpioOrangePi[64] = {
70, 37, // 0, 1
14, 15, // 2, 3
69, 89, // 4 5
@ -117,8 +116,7 @@ int ORANGEPI_PIN_MASK[4][32] = //[BANK] [INDEX]
#endif /* CONFIG_ORANGEPI_2G_IOT */
#ifdef CONFIG_ORANGEPI_PRIME
int pinToGpioOrangePi[64] =
{
int pinToGpioOrangePi[64] = {
12, 11, // 0, 1
6, 69, // 2, 3
70, 1, // 4 5
@ -212,8 +210,7 @@ int ORANGEPI_PIN_MASK[9][32] = //[BANK] [INDEX]
#endif /* PRIME */
#ifdef CONFIG_ORANGEPI_PC2
int pinToGpioOrangePi[64] =
{
int pinToGpioOrangePi[64] = {
12, 11, // 0, 1
6, 69, // 2, 3
70, 1, // 4 5
@ -306,10 +303,8 @@ int ORANGEPI_PIN_MASK[9][32] = //[BANK] [INDEX]
};
#endif /* PC2 */
#ifdef CONFIG_ORANGEPI_ZEROPLUS
int pinToGpioOrangePi [64] =
{
int pinToGpioOrangePi[64] = {
12, 11, 6, 198, 199, 1, 7, 0, 3, // From the Original Wiki - GPIO 0 through 7: wpi 0 - 7
19, 18, // I2C - SDA0, SCL0 wpi 8 - 9
15, 16, // SPI - CE1, CE0 wpi 10 - 11
@ -328,8 +323,7 @@ int pinToGpioOrangePi [64] =
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63
};
int physToGpioOrangePi [64] =
{
int physToGpioOrangePi[64] = {
-1, // 0
-1, -1, // 1, 2
12, -1,
@ -408,8 +402,7 @@ int ORANGEPI_PIN_MASK[12][32] = //[BANK] [INDEX]
#endif /* ZEROPLUS */
#ifdef CONFIG_ORANGEPI_WIN
int pinToGpioOrangePi [64] =
{
int pinToGpioOrangePi[64] = {
227, 226, // 0, 1
362, 354, // 2, 3
355, 229, // 4 5
@ -431,8 +424,7 @@ int pinToGpioOrangePi [64] =
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63
};
int physToGpioOrangePi[64] =
{
int physToGpioOrangePi[64] = {
-1, // 0
-1, -1, // 1, 2
227, -1, // 3, 4
@ -458,8 +450,7 @@ int physToGpioOrangePi[64] =
-1, -1, -1, -1, -1, -1, -1, -1 // 56-> 63
};
int physToPinOrangePi [64] =
{
int physToPinOrangePi[64] = {
-1, // 0
-1, -1, // 1, 2
0, -1, // 3, 4
@ -504,8 +495,7 @@ int ORANGEPI_PIN_MASK[12][32] = //[BANK] [INDEX]
#endif
#ifdef CONFIG_ORANGEPI_H3
int pinToGpioOrangePi [64] =
{
int pinToGpioOrangePi[64] = {
12, 11, 6, 13, 14, 1, 110, 0, // From the Original Wiki - GPIO 0 through 7: wpi 0 - 7
3, 68, // I2C - SDA0, SCL0 wpi 8 - 9
71, 64, // SPI - CE1, CE0 wpi 10 - 11
@ -524,8 +514,7 @@ int pinToGpioOrangePi [64] =
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63
};
int physToGpioOrangePi [64] =
{
int physToGpioOrangePi[64] = {
-1, // 0
-1, -1, // 1, 2
12, -1,
@ -601,8 +590,7 @@ int ORANGEPI_PIN_MASK[9][32] = //[BANK] [INDEX]
#endif
#if CONFIG_ORANGEPI_ZEROPLUS2_H3 || CONFIG_ORANGEPI_ZEROPLUS2_H5
int pinToGpioOrangePi [64] =
{
int pinToGpioOrangePi[64] = {
12, 11, 6, 0, 1, 352, 107, 353, 3, // From the Original Wiki - GPIO 0 through 7: wpi 0 - 7
19, 18, // I2C - SDA0, SCL0 wpi 8 - 9
15, 16, // SPI - CE1, CE0 wpi 10 - 11
@ -619,8 +607,7 @@ int pinToGpioOrangePi [64] =
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63
};
int physToGpioOrangePi [64] =
{
int physToGpioOrangePi[64] = {
-1, // 0
-1, -1, // 1, 2
12, -1,
@ -699,8 +686,7 @@ int ORANGEPI_PIN_MASK[12][32] = //[BANK] [INDEX]
#endif
#ifdef CONFIG_ORANGEPI_ZERO
int pinToGpioOrangePi[64] =
{
int pinToGpioOrangePi[64] = {
12, 11, 6, 198, 199, 1, 7, 0, // From the Original Wiki - GPIO 0 through 7: wpi 0 - 7
3, 19, // I2C - SDA0, SCL0 wpi 8 - 9
18, 15, // SPI - CE1, CE0 wpi 10 - 11
@ -717,8 +703,7 @@ int pinToGpioOrangePi[64] =
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63
};
int physToGpioOrangePi[64] =
{
int physToGpioOrangePi[64] = {
-1, // 0
-1, -1, // 1, 2
12, -1,
@ -747,8 +732,7 @@ int physToGpioOrangePi[64] =
-1, -1, -1, -1, -1, -1, -1, // ... 63
};
int physToPinOrangePi[64] =
{
int physToPinOrangePi[64] = {
-1, // 0
-1, -1, // 1, 2
0, -1, //3, 4
@ -797,8 +781,7 @@ int ORANGEPI_PIN_MASK[12][32] = //[BANK] [INDEX]
#ifdef CONFIG_ORANGEPI_LITE2
//pinToGpioR3 is for OrangePi H6 Lite2/OnePlus
int pinToGpioOrangePi [64] =
{
int pinToGpioOrangePi[64] = {
230, 229,
228, 117, 118,
120, 73, 119, 122, 72, 71,
@ -817,8 +800,7 @@ int pinToGpioOrangePi [64] =
};
//physToGpioR3 is for OrangePi H6 Lite2/OnePlus
int physToGpioOrangePi [64] =
{
int physToGpioOrangePi[64] = {
-1, // 0
-1, -1, // 1, 2
@ -839,8 +821,7 @@ int physToGpioOrangePi [64] =
-1, -1, -1, -1, -1, -1, -1, // ... 63
};
int physToPinOrangePi [64] =
{
int physToPinOrangePi[64] = {
-1, // 0
-1, -1, // 1, 2
0, -1,
@ -876,8 +857,7 @@ int ORANGEPI_PIN_MASK[12][32] = //[BANK] [INDEX]
#ifdef CONFIG_ORANGEPI_3
//pinToGpioR3 is for OrangePi H6 Pi 3
int pinToGpioOrangePi [64] =
{
int pinToGpioOrangePi[64] = {
122, 121,
118, 354, 355,
120, 114, 119, 362, 111, 112,
@ -896,8 +876,7 @@ int pinToGpioOrangePi [64] =
};
//physToGpioR3 is for OrangePi H6 Lite2/OnePlus
int physToGpioOrangePi [64] =
{
int physToGpioOrangePi[64] = {
-1, // 0
-1, -1, // 1, 2
@ -918,8 +897,7 @@ int physToGpioOrangePi [64] =
-1, -1, -1, -1, -1, -1, -1, // ... 63
};
int physToPinOrangePi [64] =
{
int physToPinOrangePi[64] = {
-1, // 0
-1, -1, // 1, 2
0, -1,
@ -958,8 +936,7 @@ int ORANGEPI_PIN_MASK[12][32] = //[BANK] [INDEX]
#endif
#ifdef CONFIG_ORANGEPI_ZERO2
int pinToGpioOrangePi [64] =
{
int pinToGpioOrangePi[64] = {
-1, // 0
-1, -1,
264, -1,
@ -985,8 +962,7 @@ int pinToGpioOrangePi [64] =
-1, -1, -1, -1, -1, // 63
};
int physToGpioOrangePi [64] =
{
int physToGpioOrangePi[64] = {
-1, // 0
-1, -1,
264, -1,
@ -1012,8 +988,7 @@ int physToGpioOrangePi [64] =
-1, -1, -1, -1, -1, // 63
};
int physToPinOrangePi [64] =
{
int physToPinOrangePi[64] = {
-1, // 0
-1, -1, // 1, 2
3, -1, //3, 4
@ -1058,8 +1033,7 @@ int ORANGEPI_PIN_MASK[12][32] = //[BANK] [INDEX]
#endif
#ifdef CONFIG_ORANGEPI_RK3399
int pinToGpioOrangePi[64] =
{
int pinToGpioOrangePi[64] = {
43, 44, // 0, 1
64, 148, // 2, 3
147, 80, // 4 5
@ -1139,6 +1113,7 @@ int physToPinOrangePi[64] = //return wiringPI pin
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 56
-1, -1, -1, -1, -1, -1, -1, // ... 63
};
int ORANGEPI_PIN_MASK[5][32] = //[BANK] [INDEX]
{
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }, //PA
@ -1159,8 +1134,7 @@ volatile uint32_t *gpio4_base;
// add 2019.1.8
#ifdef CONFIG_ORANGEPI_800
int pinToGpioOrangePi [64] =
{
int pinToGpioOrangePi[64] = {
43, 44, //0,1
150, 39, //2,3
40, 148, //4,5
@ -1258,8 +1232,7 @@ volatile uint32_t *gpio4_base;
#endif /* CONFIG_ORANGEPI_800 */
#ifdef CONFIG_ORANGEPI_4
int pinToGpioOrangePi [64] =
{
int pinToGpioOrangePi[64] = {
64, 65, // 0, 1
150, 145, // 2, 3
144, 33, // 4 5
@ -1276,7 +1249,6 @@ int pinToGpioOrangePi [64] =
-1, -1, //22,23
-1, -1, //24,25
-1, -1, //26,27
-1, -1, //28,29
@ -1345,6 +1317,7 @@ int physToPinOrangePi[64] = //return wiringPI pin
-1, -1, -1, -1, -1, -1, -1, // ... 63
};
int ORANGEPI_PIN_MASK[5][32] = //[BANK] [INDEX]
{
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }, //PA
@ -1365,8 +1338,7 @@ volatile uint32_t *gpio4_base;
// add 2019.1.8
#ifdef CONFIG_ORANGEPI_4_LTS
int pinToGpioOrangePi [64] =
{
int pinToGpioOrangePi[64] = {
52, 53, // 0, 1
150, 145, // 2, 3
144, 33, // 4 5
@ -1447,6 +1419,7 @@ int physToPinOrangePi[64] = //return wiringPI pin
-1, -1, -1, -1, -1, -1, -1, // ... 63
};
int ORANGEPI_PIN_MASK[5][32] = //[BANK] [INDEX]
{
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }, //PA
@ -1466,8 +1439,7 @@ volatile uint32_t *gpio4_base;
#endif /* CONFIG_ORANGEPI_4_LTS */
#ifdef CONFIG_ORANGEPI_R1PLUS
int pinToGpioOrangePi [64] =
{
int pinToGpioOrangePi[64] = {
89, 88, // 0, 1
100, 102, // 2, 3
112, 103, // 4 5
@ -1562,12 +1534,9 @@ volatile uint32_t *gpio3_base;
volatile uint32_t *cru_base;
volatile uint32_t *grf_base;
#endif /* CONFIG_ORANGEPI_R1PLUS */
// add 2020.11.26
/*
* Data for use with the boardId functions.
* The order of entries here to correspond with the PI_MODEL_X
@ -1575,8 +1544,7 @@ volatile uint32_t *grf_base;
* Only intended for the gpio command - use at your own risk!
*/
const char *piModelNames[6] =
{
const char *piModelNames[6] = {
"Unknown",
"Model A",
"Model B",
@ -1599,7 +1567,8 @@ volatile uint32_t *OrangePi_gpio;
volatile uint32_t *OrangePi_gpioC;
int pwmmode = 1;
const char * int2bin(uint32_t param) {
const char *int2bin(uint32_t param)
{
int bits = sizeof(uint32_t) * CHAR_BIT;
static char buffer[sizeof(uint32_t) * CHAR_BIT + 1];
char chars[2] = { '0', '1' };
@ -1732,7 +1701,8 @@ void writeR(unsigned int val, unsigned int addr)
#endif
}
void print_pwm_reg() {
void print_pwm_reg()
{
uint32_t val = readR(SUNXI_PWM_CTRL_REG);
uint32_t val2 = readR(SUNXI_PWM_CH0_PERIOD);
if (wiringPiDebug) {
@ -1741,13 +1711,13 @@ void print_pwm_reg() {
}
}
void sunxi_pwm_set_enable(int en) {
void sunxi_pwm_set_enable(int en)
{
int val = 0;
val = readR(SUNXI_PWM_CTRL_REG);
if (en) {
val |= (SUNXI_PWM_CH0_EN | SUNXI_PWM_SCLK_CH0_GATING);
}
else {
} else {
val &= ~(SUNXI_PWM_CH0_EN | SUNXI_PWM_SCLK_CH0_GATING);
}
if (wiringPiDebug)
@ -1757,7 +1727,8 @@ void sunxi_pwm_set_enable(int en) {
print_pwm_reg();
}
void sunxi_pwm_set_mode(int mode) {
void sunxi_pwm_set_mode(int mode)
{
int val = 0;
val = readR(SUNXI_PWM_CTRL_REG);
mode &= 1; //cover the mode to 0 or 1
@ -1776,7 +1747,8 @@ void sunxi_pwm_set_mode(int mode) {
print_pwm_reg();
}
void sunxi_pwm_set_clk(int clk) {
void sunxi_pwm_set_clk(int clk)
{
int val = 0;
if (wiringPiDebug)
printf(">>function%s,no:%d\n", __func__, __LINE__);
@ -1798,7 +1770,8 @@ void sunxi_pwm_set_clk(int clk) {
/**
* ch0 and ch1 set the same,16 bit period and 16 bit act
*/
int sunxi_pwm_get_period(void) {
int sunxi_pwm_get_period(void)
{
uint32_t period_cys = 0;
period_cys = readR(SUNXI_PWM_CH0_PERIOD); //get ch1 period_cys
if (wiringPiDebug) {
@ -1812,7 +1785,8 @@ int sunxi_pwm_get_period(void) {
return period_cys;
}
int sunxi_pwm_get_act(void) {
int sunxi_pwm_get_act(void)
{
uint32_t period_act = 0;
period_act = readR(SUNXI_PWM_CH0_PERIOD); //get ch1 period_cys
period_act &= 0xffff; //get period_act
@ -1822,7 +1796,8 @@ int sunxi_pwm_get_act(void) {
return period_act;
}
void sunxi_pwm_set_period(int period_cys) {
void sunxi_pwm_set_period(int period_cys)
{
uint32_t val = 0;
//all clear to 0
if (wiringPiDebug)
@ -1844,7 +1819,8 @@ void sunxi_pwm_set_period(int period_cys) {
print_pwm_reg();
}
void sunxi_pwm_set_act(int act_cys) {
void sunxi_pwm_set_act(int act_cys)
{
uint32_t per0 = 0;
//keep period the same, clear act_cys to 0 first
if (wiringPiDebug)
@ -1862,7 +1838,6 @@ void sunxi_pwm_set_act(int act_cys) {
print_pwm_reg();
}
int OrangePi_get_gpio_mode(int pin)
{
unsigned int regval = 0;
@ -1877,16 +1852,13 @@ int OrangePi_get_gpio_mode(int pin)
if (bank == 1) {
grf_phyaddr = PMUGRF_BASE + ((index >> 3) << 2) + 0x10;
ddr_phyaddr = GPIO1_BASE + GPIO_SWPORTA_DDR_OFFSET;
}
else if(bank == 2){
} else if (bank == 2) {
grf_phyaddr = GRF_BASE + ((index >> 3) << 2);
ddr_phyaddr = GPIO2_BASE + GPIO_SWPORTA_DDR_OFFSET;
}
else if(bank == 4){
} else if (bank == 4) {
grf_phyaddr = GRF_BASE + ((index >> 3) << 2) + 0x20;
ddr_phyaddr = GPIO4_BASE + GPIO_SWPORTA_DDR_OFFSET;
}
else ;
} else;
if (ORANGEPI_PIN_MASK[bank - 1][index] != -1) {
regval = readR(grf_phyaddr);
mode = (regval >> (offset << 1)) & 0x3; //获取控制模式的那两位的值
@ -1907,32 +1879,26 @@ int OrangePi_get_gpio_mode(int pin)
if (0 == (index >> 3)) //gpio2_ax
{
grf_phyaddr = GRF_BASE + 0x20;
}
else if(3 == (index >> 3))//gpio2_dx
} else if (3 == (index >> 3)) //gpio2_dx
{
grf_phyaddr = GRF_BASE + 0x34;
}
}
else if(bank == 3){
} else if (bank == 3) {
//grf_phyaddr = GRF_BASE + ((index >> 3) << 2) +0x20;
ddr_phyaddr = GPIO3_BASE + GPIO_SWPORTA_DDR_OFFSET;
if (0 == (index >> 3))
{
if (0 == (index >> 3)) {
if (4 == offset) //gpio3_a4
{
grf_phyaddr = GRF_BASE + 0x38;
}
else//gpio3_a567
} else //gpio3_a567
{
grf_phyaddr = GRF_BASE + 0x3c;
}
}
else if(2 == (index >> 3)) //gpio3_c
} else if (2 == (index >> 3)) //gpio3_c
{
grf_phyaddr = GRF_BASE + 0x48;
}
}
else;
} else;
if (ORANGEPI_PIN_MASK[bank - 1][index] != -1) {
regval = readR(grf_phyaddr);
writeR(0xffff9877, 0xff440240);
@ -1940,9 +1906,7 @@ int OrangePi_get_gpio_mode(int pin)
if (3 == bank && (0 == (index >> 3))) //gpio3_ax需要写3位
{
mode = (regval >> ((offset % 5) * 3)) & 0x7;
}
else
{
} else {
mode = (regval >> (offset << 1)) & 0x3;
}
if (mode == 0) {
@ -1957,8 +1921,7 @@ int OrangePi_get_gpio_mode(int pin)
if (bank == 11) {
phyaddr = GPIOL_BASE + ((index >> 3) << 2);
}
else
} else
phyaddr = GPIO_BASE_MAP + (bank * 36) + ((index >> 3) << 2);
/* Ignore unused gpio */
@ -1991,8 +1954,7 @@ int OrangePi_set_gpio_mode(int pin, int mode)
if (bank == 11) {
phyaddr = GPIOL_BASE + ((index >> 3) << 2);
}
else
} else
phyaddr = GPIO_BASE_MAP + (bank * 36) + ((index >> 3) << 2);
#endif
@ -2026,13 +1988,11 @@ int OrangePi_set_gpio_mode(int pin, int mode)
cru_phyaddr = CRU_BASE + CRU_CLKGATE_CON31_OFFSET;
grf_phyaddr = GRF_BASE + ((index >> 3) << 2);
gpio_phyaddr = GPIO2_BASE + GPIO_SWPORTA_DDR_OFFSET;
}
else if(bank == 4){
} else if (bank == 4) {
cru_phyaddr = CRU_BASE + CRU_CLKGATE_CON31_OFFSET;
grf_phyaddr = GRF_BASE + ((index >> 3) << 2) + 0x20;
gpio_phyaddr = GPIO4_BASE + GPIO_SWPORTA_DDR_OFFSET;
}
else;
} else;
#elif (defined CONFIG_ORANGEPI_R1PLUS)
if (bank == 2) { //gpio2
@ -2042,33 +2002,27 @@ int OrangePi_set_gpio_mode(int pin, int mode)
if (0 == (index >> 3)) //gpio2_ax
{
grf_phyaddr = GRF_BASE + 0x20;
}
else if(3 == (index >> 3))//gpio2_dx
} else if (3 == (index >> 3)) //gpio2_dx
{
grf_phyaddr = GRF_BASE + 0x34;
}
}
else if(bank == 3){
} else if (bank == 3) {
cru_phyaddr = CRU_BASE + CRU_CLKGATE_CON16_OFFSET;
//grf_phyaddr = GRF_BASE + ((index >> 3) << 2) +0x20;
gpio_phyaddr = GPIO3_BASE + GPIO_SWPORTA_DDR_OFFSET;
if (0 == (index >> 3))
{
if (0 == (index >> 3)) {
if (4 == offset) //gpio3_a4
{
grf_phyaddr = GRF_BASE + 0x38;
}
else//gpio3_a567
} else //gpio3_a567
{
grf_phyaddr = GRF_BASE + 0x3c;
}
}
else if(2 == (index >> 3)) //gpio3_c
} else if (2 == (index >> 3)) //gpio3_c
{
grf_phyaddr = GRF_BASE + 0x48;
}
}
else;
} else;
#endif
/* Ignore unused gpio */
@ -2108,8 +2062,7 @@ int OrangePi_set_gpio_mode(int pin, int mode)
{
regval |= 0xffff0000;
regval &= ~(0x7 << ((offset % 5) * 3));
}
else //其他的写两位
} else //其他的写两位
{
regval |= 0xffff0000;
regval &= ~(0x3 << (offset << 1));
@ -2157,8 +2110,7 @@ int OrangePi_set_gpio_mode(int pin, int mode)
{
regval |= 0xffff0000;
regval &= ~(0x7 << ((offset % 5) * 3));
}
else //其他的写两位
} else //其他的写两位
{
regval |= 0xffff0000;
regval &= ~(0x3 << (offset << 1));
@ -2204,8 +2156,7 @@ int OrangePi_set_gpio_mode(int pin, int mode)
pwmSetMode(PWM_MODE_MS);
sunxi_pwm_set_clk(PWM_CLK_DIV_120); //default clk:24M/120
delayMicroseconds(200);
}
else {
} else {
printf("Unknow mode\n");
}
} else
@ -2245,20 +2196,17 @@ int OrangePi_set_gpio_pullUpDnControl(int pin, int pud)
bit_value = 3;
else
bit_value = 1;
}
else if (PUD_DOWN == pud) {
} else if (PUD_DOWN == pud) {
if (pin < 8 || (bank == 2 && index > 15)) /* gpio0a, gpio2c, gpio2d */
bit_value = 1;
else
bit_value = 2;
}
else if (PUD_OFF == pud) {
} else if (PUD_OFF == pud) {
bit_value = 0;
}
#else
unsigned int pullOffset = 0x1C;
switch (pud)
{
switch (pud) {
case PUD_OFF:
bit_value = SUNXI_PUD_OFF;
break;
@ -2275,16 +2223,13 @@ int OrangePi_set_gpio_pullUpDnControl(int pin, int pud)
offset = ((index - ((index >> 4) << 4)) << 1);
pullOffset = 0x1C;
if (bank == 11)
{
if (bank == 11) {
phyaddr = pullOffset + GPIOL_BASE + ((index >> 4) << 2);
}
else
} else
phyaddr = pullOffset + GPIO_BASE_MAP + (bank * 36) + ((index >> 4) << 2);
#endif
/* Ignore unused gpio */
if (ORANGEPI_PIN_MASK[bank][index] != -1)
{
if (ORANGEPI_PIN_MASK[bank][index] != -1) {
if (wiringPiDebug)
printf("bank: %d, index: %d\n", bank, index);
@ -2309,8 +2254,7 @@ int OrangePi_set_gpio_pullUpDnControl(int pin, int pud)
if (wiringPiDebug)
printf("over reg val: %#x\n", regval);
}
else
} else
printf("Pin pull control failed!\n");
return 0;
@ -2366,8 +2310,7 @@ int OrangePi_digitalWrite(int pin, int value)
if (bank == 11) {
phyaddr = GPIOL_BASE + 0x10;
}
else
} else
phyaddr = GPIO_BASE_MAP + (bank * 36) + 0x10;
#endif
@ -2419,27 +2362,22 @@ int OrangePi_digitalWrite(int pin, int value)
if (bank == 1) {
phyaddr = GPIO1_BASE + GPIO_SWPORTA_DR_OFFSET;
cru_phyaddr = PMUCRU_BASE + PMUCRU_CLKGATE_CON1_OFFSET;
}
else if(bank == 2){
} else if (bank == 2) {
phyaddr = GPIO2_BASE + GPIO_SWPORTA_DR_OFFSET;
cru_phyaddr = CRU_BASE + CRU_CLKGATE_CON31_OFFSET;
}
else if(bank == 4){
} else if (bank == 4) {
phyaddr = GPIO4_BASE + GPIO_SWPORTA_DR_OFFSET;
cru_phyaddr = CRU_BASE + CRU_CLKGATE_CON31_OFFSET;
}
else;
} else;
#elif (defined CONFIG_ORANGEPI_R1PLUS)
if (bank == 2) {
phyaddr = GPIO2_BASE + GPIO_SWPORTA_DR_OFFSET;
cru_phyaddr = CRU_BASE + CRU_CLKGATE_CON16_OFFSET;
}
else if(bank == 3){
} else if (bank == 3) {
phyaddr = GPIO3_BASE + GPIO_SWPORTA_DR_OFFSET;
cru_phyaddr = CRU_BASE + CRU_CLKGATE_CON16_OFFSET;
}
else;
} else;
#endif
/* Ignore unused gpio */
@ -2490,8 +2428,7 @@ int OrangePi_digitalRead(int pin)
if (bank == 11) {
phyaddr = GPIOL_BASE + 0x10;
}
else
} else
phyaddr = GPIO_BASE_MAP + (bank * 36) + 0x10;
#endif
@ -2596,7 +2533,6 @@ int isOrangePi(void)
/* Support: OrangePi R1plus */
char *OrangePi_string = "rk3328";
#else
/* Non-support */
char *OrangePi_string = "none";

View File

@ -122,7 +122,6 @@
#define GRF_GPIO4C_IOMUX_OFFSET 0x28
#define GRF_GPIO4D_IOMUX_OFFSET 0x2c
#define CRU_BASE 0xff760000
#define PMUCRU_BASE 0xff750000
#define CRU_CLKGATE_CON31_OFFSET 0x037c //bit 3 4 5
@ -142,7 +141,6 @@ extern volatile unsigned int *gpio4_base;
#endif /* CONFIG_ORANGEPI_RK3399 */
//csy 2019.1.8
/*********** OrangePi R1PLUS *************/
#if CONFIG_ORANGEPI_R1PLUS
@ -180,12 +178,9 @@ extern volatile unsigned int *gpio3_base;
extern volatile unsigned int *cru_base;
extern volatile unsigned int *grf_base;
#endif /* CONFIG_ORANGEPI_R1PLUS */
//FG 2020.11.26
/****************** Global data *********************/
/* Current version */
#define PI_MAKER_ORANGEPI 4
@ -197,7 +192,6 @@ extern volatile unsigned int *grf_base;
#define ORANGEPI_MEM_INFO MEM_INFO
#define GPIO_PWM GPIO_PWM_OP
//sunxi_pwm
#define SUNXI_PWM_BASE (0x01c21400)
#define SUNXI_PWM_CTRL_REG (SUNXI_PWM_BASE)
@ -261,7 +255,6 @@ extern int sunxi_pwm_get_act(void);
extern void sunxi_pwm_set_period(int period_cys);
extern void sunxi_pwm_set_act(int act_cys);
#ifdef CONFIG_ORANGEPI
extern const char *piModelNames[6];
#endif
@ -281,6 +274,5 @@ extern int ORANGEPI_PIN_MASK[5][32];
#elif CONFIG_ORANGEPI_R1PLUS
extern int ORANGEPI_PIN_MASK[5][32];
#endif
#endif