|
|
|
@ -971,7 +971,111 @@ volatile uint32_t *gpio4_base;
|
|
|
|
|
#endif /* CONFIG_ORANGEPI_4 */ |
|
|
|
|
// add 2019.1.8
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_ORANGEPI_4B |
|
|
|
|
int pinToGpioOrangePi [64] = |
|
|
|
|
{ |
|
|
|
|
150, 33, // 0, 1
|
|
|
|
|
50, 35, // 2, 3
|
|
|
|
|
92, 54, // 4 5
|
|
|
|
|
55, 56, // 6, 7
|
|
|
|
|
149, -1, // 8, 9
|
|
|
|
|
-1, -1, //10,11
|
|
|
|
|
|
|
|
|
|
-1, -1, //12,13
|
|
|
|
|
|
|
|
|
|
-1, -1, //14,15
|
|
|
|
|
-1, -1, //16,17
|
|
|
|
|
-1, -1, //18,19
|
|
|
|
|
-1, -1, //20,21
|
|
|
|
|
-1, -1, //22,23
|
|
|
|
|
-1, -1, //24,25
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-1, -1, //26,27
|
|
|
|
|
|
|
|
|
|
-1, -1, //28,29
|
|
|
|
|
-1, -1, //30,31
|
|
|
|
|
|
|
|
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47
|
|
|
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,// ... 63
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
int physToGpioOrangePi[64] =//head num map to OrangePi
|
|
|
|
|
{ |
|
|
|
|
-1, // 0
|
|
|
|
|
-1, -1, // 1, 2
|
|
|
|
|
-1, -1, // 3, 4
|
|
|
|
|
-1, -1, // 5, 6
|
|
|
|
|
150, -1, // 7, 8
|
|
|
|
|
-1, -1, // 9, 10
|
|
|
|
|
33, 50, // 11, 12
|
|
|
|
|
35, -1, // 13, 14
|
|
|
|
|
92, 54, // 15, 16
|
|
|
|
|
-1, 55, // 17, 18
|
|
|
|
|
-1, -1, // 19, 20
|
|
|
|
|
-1, 56, // 21, 22
|
|
|
|
|
-1, -1, // 23, 24
|
|
|
|
|
-1, 149, // 25, 26
|
|
|
|
|
-1, -1, // 27, 28
|
|
|
|
|
-1, -1, // 29, 30
|
|
|
|
|
-1, -1, // 31, 32
|
|
|
|
|
-1, -1, // 33, 34
|
|
|
|
|
-1, -1, // 35, 36
|
|
|
|
|
-1, -1, // 37, 38
|
|
|
|
|
-1, -1, // 39, 40
|
|
|
|
|
// Padding:
|
|
|
|
|
-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 physToPinOrangePi[64] = //return wiringPI pin
|
|
|
|
|
{ |
|
|
|
|
-1, // 0
|
|
|
|
|
-1, -1, // 1, 2
|
|
|
|
|
-1, -1, //3, 4
|
|
|
|
|
-1, -1, //5, 6
|
|
|
|
|
0, -1, //7, 8
|
|
|
|
|
-1, -1, //9,10
|
|
|
|
|
1, 2, //11,12
|
|
|
|
|
3, -1, //13,14
|
|
|
|
|
4, 5, //15,16
|
|
|
|
|
-1, 6, //17,18
|
|
|
|
|
-1, -1, //19,20
|
|
|
|
|
-1, 7, //21,22
|
|
|
|
|
-1, -1, //23, 24
|
|
|
|
|
-1, 8, // 25, 26
|
|
|
|
|
|
|
|
|
|
-1, -1, //27, 28
|
|
|
|
|
-1, -1, //29, 30
|
|
|
|
|
-1, -1, //31, 32
|
|
|
|
|
-1, -1, //33, 34
|
|
|
|
|
-1, -1, //35, 36
|
|
|
|
|
-1, -1, //37, 38
|
|
|
|
|
-1, -1, //39, 40
|
|
|
|
|
// Padding:
|
|
|
|
|
|
|
|
|
|
-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
|
|
|
|
|
{ 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,},//PB
|
|
|
|
|
{ 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,},//PC
|
|
|
|
|
{ 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,},//PD
|
|
|
|
|
{ 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,},//PD
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
volatile uint32_t *gpio2_base; |
|
|
|
|
volatile uint32_t *cru_base; |
|
|
|
|
volatile uint32_t *grf_base; |
|
|
|
|
volatile uint32_t *pmugrf_base; |
|
|
|
|
volatile uint32_t *pmucru_base; |
|
|
|
|
volatile uint32_t *gpio1_base; |
|
|
|
|
volatile uint32_t *gpio4_base; |
|
|
|
|
#endif /* CONFIG_ORANGEPI_4B */ |
|
|
|
|
// add 2020.02.16
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Data for use with the boardId functions. |
|
|
|
@ -997,6 +1101,8 @@ const char *piModelNames[6] =
|
|
|
|
|
"OrangePi H3 family", |
|
|
|
|
#elif CONFIG_ORANGEPI_ZERO |
|
|
|
|
"OrangePi Zero", |
|
|
|
|
#elif CONFIG_ORANGEPI_4B |
|
|
|
|
"OrangePi 4B",
|
|
|
|
|
#endif |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -1033,7 +1139,7 @@ unsigned int readR(unsigned int addr)
|
|
|
|
|
else /* Group A, B and D */ |
|
|
|
|
val = *((char *)OrangePi_gpio + mmap_seek); |
|
|
|
|
return val; |
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4) |
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4 || defined CONFIG_ORANGEPI_4B) |
|
|
|
|
unsigned int val = 0; |
|
|
|
|
unsigned int mmap_base = (addr & ~MAP_MASK); |
|
|
|
|
unsigned int mmap_seek = (addr - mmap_base); |
|
|
|
@ -1081,7 +1187,7 @@ void writeR(unsigned int val, unsigned int addr)
|
|
|
|
|
else |
|
|
|
|
*((char *)OrangePi_gpio + mmap_seek) = val; |
|
|
|
|
|
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4) |
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4 || defined CONFIG_ORANGEPI_4B) |
|
|
|
|
unsigned int mmap_base = (addr & ~MAP_MASK); |
|
|
|
|
unsigned int mmap_seek = (addr - mmap_base); |
|
|
|
|
if(mmap_base == CRU_BASE)
|
|
|
|
@ -1245,12 +1351,12 @@ void sunxi_pwm_set_act(int act_cys) {
|
|
|
|
|
int OrangePi_get_gpio_mode(int pin) |
|
|
|
|
{ |
|
|
|
|
unsigned int regval = 0; |
|
|
|
|
unsigned int bank = pin >> 5; //算出 pin 属于哪一组 H6 有 2/3/5/6/7
|
|
|
|
|
unsigned int index = pin - (bank << 5); //算出 pin 属于组中的第多少个
|
|
|
|
|
unsigned int bank = pin >> 5; //<EFBFBD><EFBFBD><EFBFBD> pin <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD> H6 <EFBFBD><EFBFBD> 2/3/5/6/7
|
|
|
|
|
unsigned int index = pin - (bank << 5); //<EFBFBD><EFBFBD><EFBFBD> pin <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еĵڶ<EFBFBD><EFBFBD>ٸ<EFBFBD>
|
|
|
|
|
unsigned int phyaddr = 0; |
|
|
|
|
unsigned char mode = -1; |
|
|
|
|
|
|
|
|
|
#if (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4) |
|
|
|
|
#if (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4 || defined CONFIG_ORANGEPI_4B) |
|
|
|
|
unsigned int grf_phyaddr = 0, ddr_phyaddr = 0; |
|
|
|
|
int offset = ((index - ((index >> 3) << 3))); |
|
|
|
|
if(bank == 1){ |
|
|
|
@ -1308,7 +1414,7 @@ int OrangePi_set_gpio_mode(int pin, int mode)
|
|
|
|
|
unsigned int phyaddr = 0; |
|
|
|
|
#ifdef CONFIG_ORANGEPI_2G_IOT |
|
|
|
|
unsigned int base_address = 0; |
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4) |
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4 || defined CONFIG_ORANGEPI_4B) |
|
|
|
|
int offset = ((index - ((index >> 3) << 3))); |
|
|
|
|
unsigned int cru_phyaddr, grf_phyaddr, gpio_phyaddr; |
|
|
|
|
#else |
|
|
|
@ -1340,7 +1446,7 @@ int OrangePi_set_gpio_mode(int pin, int mode)
|
|
|
|
|
phyaddr = base_address + OEN_SET_OUT_REGISTER; |
|
|
|
|
else |
|
|
|
|
printf("Invalid mode\n"); |
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4) |
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4 || defined CONFIG_ORANGEPI_4B) |
|
|
|
|
if(bank == 1){ |
|
|
|
|
cru_phyaddr = PMUCRU_BASE + PMUCRU_CLKGATE_CON1_OFFSET; |
|
|
|
|
grf_phyaddr = PMUGRF_BASE + ((index >> 3) << 2) + 0x10; |
|
|
|
@ -1362,7 +1468,7 @@ int OrangePi_set_gpio_mode(int pin, int mode)
|
|
|
|
|
#endif |
|
|
|
|
/* Ignore unused gpio */ |
|
|
|
|
if (ORANGEPI_PIN_MASK[bank][index] != -1) { |
|
|
|
|
#if ! (defined CONFIG_ORANGEPI_2G_IOT || defined CONFIG_ORANGEPI_RK3399 || CONFIG_ORANGEPI_4) |
|
|
|
|
#if ! (defined CONFIG_ORANGEPI_2G_IOT || defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4 || defined CONFIG_ORANGEPI_4B) |
|
|
|
|
regval = readR(phyaddr); |
|
|
|
|
if (wiringPiDebug) |
|
|
|
|
printf("Before read reg val: 0x%x offset:%d\n",regval,offset); |
|
|
|
@ -1375,7 +1481,7 @@ int OrangePi_set_gpio_mode(int pin, int mode)
|
|
|
|
|
#ifdef CONFIG_ORANGEPI_2G_IOT |
|
|
|
|
writeR(GPIO_BIT(index), phyaddr); |
|
|
|
|
|
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4) |
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4 || defined CONFIG_ORANGEPI_4B) |
|
|
|
|
writeR(0xffff0180, cru_phyaddr); |
|
|
|
|
regval = readR(grf_phyaddr); |
|
|
|
|
regval |= 0x3 << ((offset << 1) | 0x10); |
|
|
|
@ -1466,7 +1572,7 @@ int OrangePi_digitalWrite(int pin, int value)
|
|
|
|
|
#ifdef CONFIG_ORANGEPI_2G_IOT |
|
|
|
|
unsigned int base_address = 0; |
|
|
|
|
|
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4) |
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4 || defined CONFIG_ORANGEPI_4B) |
|
|
|
|
unsigned int regval = 0; |
|
|
|
|
unsigned int cru_phyaddr = 0; |
|
|
|
|
|
|
|
|
@ -1524,7 +1630,7 @@ int OrangePi_digitalWrite(int pin, int value)
|
|
|
|
|
else |
|
|
|
|
printf("Invalid value\n"); |
|
|
|
|
|
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4) |
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4 || defined CONFIG_ORANGEPI_4B) |
|
|
|
|
if(bank == 1){ |
|
|
|
|
phyaddr = GPIO1_BASE + GPIO_SWPORTA_DR_OFFSET; |
|
|
|
|
cru_phyaddr = PMUCRU_BASE + PMUCRU_CLKGATE_CON1_OFFSET; |
|
|
|
@ -1546,7 +1652,7 @@ int OrangePi_digitalWrite(int pin, int value)
|
|
|
|
|
writeR(GPIO_BIT(index), phyaddr); |
|
|
|
|
|
|
|
|
|
#else |
|
|
|
|
#if (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4) |
|
|
|
|
#if (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4 || defined CONFIG_ORANGEPI_4B) |
|
|
|
|
writeR(0xffff0180, cru_phyaddr); |
|
|
|
|
#endif |
|
|
|
|
regval = readR(phyaddr); |
|
|
|
@ -1579,7 +1685,7 @@ int OrangePi_digitalRead(int pin)
|
|
|
|
|
int bank = pin >> 5; |
|
|
|
|
int index = pin - (bank << 5); |
|
|
|
|
int val; |
|
|
|
|
#if ! (defined CONFIG_ORANGEPI_2G_IOT || defined CONFIG_ORANGEPI_RK3399 || CONFIG_ORANGEPI_4) |
|
|
|
|
#if ! (defined CONFIG_ORANGEPI_2G_IOT || defined CONFIG_ORANGEPI_RK3399 || CONFIG_ORANGEPI_4 || defined CONFIG_ORANGEPI_4B) |
|
|
|
|
|
|
|
|
|
unsigned int phyaddr; |
|
|
|
|
|
|
|
|
@ -1616,7 +1722,7 @@ int OrangePi_digitalRead(int pin)
|
|
|
|
|
phys_SET_R = base_address + SET_REGISTER; |
|
|
|
|
phys_VAL_R = base_address + VAL_REGISTER; |
|
|
|
|
|
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4) |
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4 || defined CONFIG_ORANGEPI_4B) |
|
|
|
|
unsigned int phyaddr; |
|
|
|
|
if(bank == 1) |
|
|
|
|
phyaddr = GPIO1_BASE + GPIO_EXT_PORTA_OFFSET;
|
|
|
|
@ -1673,7 +1779,7 @@ int isOrangePi(void)
|
|
|
|
|
#elif CONFIG_ORANGEPI_LITE2 || CONFIG_ORANGEPI_3 |
|
|
|
|
/* Support: OrangePi zero */ |
|
|
|
|
char *OrangePi_string = "sun50iw6"; |
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4) |
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4 || defined CONFIG_ORANGEPI_4B) |
|
|
|
|
/* Support: OrangePi RK3399 */ |
|
|
|
|
char *OrangePi_string = "rk3399"; |
|
|
|
|
|
|
|
|
@ -1697,7 +1803,7 @@ int isOrangePi(void)
|
|
|
|
|
|
|
|
|
|
fclose(cpuFd); |
|
|
|
|
|
|
|
|
|
#if (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4) |
|
|
|
|
#if (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4 || defined CONFIG_ORANGEPI_4B) |
|
|
|
|
strcpy(line, "Hardware : Rockchip rk3399 Family"); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|