|
|
|
@ -864,6 +864,114 @@ volatile uint32_t *gpio4_base;
|
|
|
|
|
// add 2019.1.8
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_ORANGEPI_4 |
|
|
|
|
int pinToGpioOrangePi [64] = |
|
|
|
|
{ |
|
|
|
|
64, 65, // 0, 1
|
|
|
|
|
150, 145, // 2, 3
|
|
|
|
|
144, 33, // 4 5
|
|
|
|
|
50, 35, // 6, 7
|
|
|
|
|
92, 54, // 8, 9
|
|
|
|
|
55, 40, //10,11
|
|
|
|
|
|
|
|
|
|
39, 56, //12,13
|
|
|
|
|
|
|
|
|
|
41, 42, //14,15
|
|
|
|
|
149, 64, //16,17
|
|
|
|
|
65, -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
|
|
|
|
|
64, -1, // 3, 4
|
|
|
|
|
65, -1, // 5, 6
|
|
|
|
|
150, 145, // 7, 8
|
|
|
|
|
-1, 144, // 9, 10
|
|
|
|
|
33, 50, // 11, 12
|
|
|
|
|
35, -1, // 13, 14
|
|
|
|
|
92, 54, // 15, 16
|
|
|
|
|
-1, 55, // 17, 18
|
|
|
|
|
40, -1, // 19, 20
|
|
|
|
|
39, 56, // 21, 22
|
|
|
|
|
41, 42, // 23, 24
|
|
|
|
|
-1, 149, // 25, 26
|
|
|
|
|
64, 65, // 27, 28
|
|
|
|
|
-1, -1, // 29, 30
|
|
|
|
|
-1, 76, // 31, 32
|
|
|
|
|
-1, -1, // 33, 34
|
|
|
|
|
-1, 73, // 35, 36
|
|
|
|
|
-1, 74, // 37, 38
|
|
|
|
|
-1, 75, // 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
|
|
|
|
|
0, -1, //3, 4
|
|
|
|
|
1, -1, //5, 6
|
|
|
|
|
2, 3, //7, 8
|
|
|
|
|
-1, 4, //9,10
|
|
|
|
|
5, 6, //11,12
|
|
|
|
|
7, -1, //13,14
|
|
|
|
|
8, 9, //15,16
|
|
|
|
|
-1, 10, //17,18
|
|
|
|
|
11, -1, //19,20
|
|
|
|
|
12, 13, //21,22
|
|
|
|
|
14, 15, //23, 24
|
|
|
|
|
-1, 16, // 25, 26
|
|
|
|
|
|
|
|
|
|
17, 18, //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_4 */ |
|
|
|
|
// add 2019.1.8
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Data for use with the boardId functions. |
|
|
|
@ -925,7 +1033,7 @@ unsigned int readR(unsigned int addr)
|
|
|
|
|
else /* Group A, B and D */ |
|
|
|
|
val = *((char *)OrangePi_gpio + mmap_seek); |
|
|
|
|
return val; |
|
|
|
|
#elif CONFIG_ORANGEPI_RK3399 |
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4) |
|
|
|
|
unsigned int val = 0; |
|
|
|
|
unsigned int mmap_base = (addr & ~MAP_MASK); |
|
|
|
|
unsigned int mmap_seek = (addr - mmap_base); |
|
|
|
@ -973,7 +1081,7 @@ void writeR(unsigned int val, unsigned int addr)
|
|
|
|
|
else |
|
|
|
|
*((char *)OrangePi_gpio + mmap_seek) = val; |
|
|
|
|
|
|
|
|
|
#elif CONFIG_ORANGEPI_RK3399 |
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4) |
|
|
|
|
unsigned int mmap_base = (addr & ~MAP_MASK); |
|
|
|
|
unsigned int mmap_seek = (addr - mmap_base); |
|
|
|
|
if(mmap_base == CRU_BASE)
|
|
|
|
@ -1142,7 +1250,7 @@ int OrangePi_get_gpio_mode(int pin)
|
|
|
|
|
unsigned int phyaddr = 0; |
|
|
|
|
unsigned char mode = -1; |
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_ORANGEPI_RK3399 |
|
|
|
|
#if (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4) |
|
|
|
|
unsigned int grf_phyaddr = 0, ddr_phyaddr = 0; |
|
|
|
|
int offset = ((index - ((index >> 3) << 3))); |
|
|
|
|
if(bank == 1){ |
|
|
|
@ -1200,7 +1308,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 CONFIG_ORANGEPI_RK3399 |
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4) |
|
|
|
|
int offset = ((index - ((index >> 3) << 3))); |
|
|
|
|
unsigned int cru_phyaddr, grf_phyaddr, gpio_phyaddr; |
|
|
|
|
#else |
|
|
|
@ -1232,7 +1340,7 @@ int OrangePi_set_gpio_mode(int pin, int mode)
|
|
|
|
|
phyaddr = base_address + OEN_SET_OUT_REGISTER; |
|
|
|
|
else |
|
|
|
|
printf("Invalid mode\n"); |
|
|
|
|
#elif CONFIG_ORANGEPI_RK3399 |
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4) |
|
|
|
|
if(bank == 1){ |
|
|
|
|
cru_phyaddr = PMUCRU_BASE + PMUCRU_CLKGATE_CON1_OFFSET; |
|
|
|
|
grf_phyaddr = PMUGRF_BASE + ((index >> 3) << 2) + 0x10; |
|
|
|
@ -1254,7 +1362,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) |
|
|
|
|
#if ! (defined CONFIG_ORANGEPI_2G_IOT || defined CONFIG_ORANGEPI_RK3399 || CONFIG_ORANGEPI_4) |
|
|
|
|
regval = readR(phyaddr); |
|
|
|
|
if (wiringPiDebug) |
|
|
|
|
printf("Before read reg val: 0x%x offset:%d\n",regval,offset); |
|
|
|
@ -1267,7 +1375,7 @@ int OrangePi_set_gpio_mode(int pin, int mode)
|
|
|
|
|
#ifdef CONFIG_ORANGEPI_2G_IOT |
|
|
|
|
writeR(GPIO_BIT(index), phyaddr); |
|
|
|
|
|
|
|
|
|
#elif CONFIG_ORANGEPI_RK3399 |
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4) |
|
|
|
|
writeR(0xffff0180, cru_phyaddr); |
|
|
|
|
regval = readR(grf_phyaddr); |
|
|
|
|
regval |= 0xffff << 16; |
|
|
|
@ -1292,7 +1400,7 @@ int OrangePi_set_gpio_mode(int pin, int mode)
|
|
|
|
|
writeR(GPIO_BIT(index), phyaddr); |
|
|
|
|
/* Set default value as 0 */ |
|
|
|
|
writeR(GPIO_BIT(index), base_address + CLR_REGISTER); |
|
|
|
|
#elif CONFIG_ORANGEPI_RK3399 |
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4) |
|
|
|
|
writeR(0xffff0180, cru_phyaddr); |
|
|
|
|
regval = readR(grf_phyaddr); |
|
|
|
|
regval |= 0xffff << 16; |
|
|
|
@ -1358,7 +1466,7 @@ int OrangePi_digitalWrite(int pin, int value)
|
|
|
|
|
#ifdef CONFIG_ORANGEPI_2G_IOT |
|
|
|
|
unsigned int base_address = 0; |
|
|
|
|
|
|
|
|
|
#elif CONFIG_ORANGEPI_RK3399 |
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4) |
|
|
|
|
unsigned int regval = 0; |
|
|
|
|
unsigned int cru_phyaddr = 0; |
|
|
|
|
|
|
|
|
@ -1416,7 +1524,7 @@ int OrangePi_digitalWrite(int pin, int value)
|
|
|
|
|
else |
|
|
|
|
printf("Invalid value\n"); |
|
|
|
|
|
|
|
|
|
#elif CONFIG_ORANGEPI_RK3399 |
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4) |
|
|
|
|
if(bank == 1){ |
|
|
|
|
phyaddr = GPIO1_BASE + GPIO_SWPORTA_DR_OFFSET; |
|
|
|
|
cru_phyaddr = PMUCRU_BASE + PMUCRU_CLKGATE_CON1_OFFSET; |
|
|
|
@ -1438,7 +1546,7 @@ int OrangePi_digitalWrite(int pin, int value)
|
|
|
|
|
writeR(GPIO_BIT(index), phyaddr); |
|
|
|
|
|
|
|
|
|
#else |
|
|
|
|
#ifdef CONFIG_ORANGEPI_RK3399 |
|
|
|
|
#if (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4) |
|
|
|
|
writeR(0xffff0180, cru_phyaddr); |
|
|
|
|
#endif |
|
|
|
|
regval = readR(phyaddr); |
|
|
|
@ -1471,7 +1579,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) |
|
|
|
|
#if ! (defined CONFIG_ORANGEPI_2G_IOT || defined CONFIG_ORANGEPI_RK3399 || CONFIG_ORANGEPI_4) |
|
|
|
|
|
|
|
|
|
unsigned int phyaddr; |
|
|
|
|
|
|
|
|
@ -1508,7 +1616,7 @@ int OrangePi_digitalRead(int pin)
|
|
|
|
|
phys_SET_R = base_address + SET_REGISTER; |
|
|
|
|
phys_VAL_R = base_address + VAL_REGISTER; |
|
|
|
|
|
|
|
|
|
#elif CONFIG_ORANGEPI_RK3399 |
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4) |
|
|
|
|
unsigned int phyaddr; |
|
|
|
|
if(bank == 1) |
|
|
|
|
phyaddr = GPIO1_BASE + GPIO_EXT_PORTA_OFFSET;
|
|
|
|
@ -1565,7 +1673,7 @@ int isOrangePi(void)
|
|
|
|
|
#elif CONFIG_ORANGEPI_LITE2 || CONFIG_ORANGEPI_3 |
|
|
|
|
/* Support: OrangePi zero */ |
|
|
|
|
char *OrangePi_string = "sun50iw6"; |
|
|
|
|
#elif CONFIG_ORANGEPI_RK3399 |
|
|
|
|
#elif (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4) |
|
|
|
|
/* Support: OrangePi RK3399 */ |
|
|
|
|
char *OrangePi_string = "rk3399"; |
|
|
|
|
|
|
|
|
@ -1574,9 +1682,10 @@ int isOrangePi(void)
|
|
|
|
|
/* Non-support */ |
|
|
|
|
char *OrangePi_string = "none"; |
|
|
|
|
#endif |
|
|
|
|
//printf("OrangePi String is %s\n", OrangePi_string);
|
|
|
|
|
|
|
|
|
|
return 1; |
|
|
|
|
//printf("OrangePi String is %s\n", OrangePi_string);
|
|
|
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
|
|
if ((cpuFd = fopen("/proc/cpuinfo", "r")) == NULL) |
|
|
|
|
piGpioLayoutOops ("Unable to open /proc/cpuinfo") ; |
|
|
|
@ -1588,7 +1697,7 @@ int isOrangePi(void)
|
|
|
|
|
|
|
|
|
|
fclose(cpuFd); |
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_ORANGEPI_RK3399 |
|
|
|
|
#if (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4) |
|
|
|
|
strcpy(line, "Hardware : Rockchip rk3399 Family"); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|