Skip to content

Commit

Permalink
Support Orange Pi 5 Pro
Browse files Browse the repository at this point in the history
  • Loading branch information
baiywt committed Dec 19, 2023
1 parent d6dd560 commit 08a843c
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 4 deletions.
1 change: 1 addition & 0 deletions examples/blink.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ unsigned char getGpioNum(void)
case PI_MODEL_H3:
case PI_MODEL_RK3399:
case PI_MODEL_4:
case PI_MODEL_5_PRO:
case PI_MODEL_5_MAX:
case PI_MODEL_5_PLUS:
case PI_MODEL_900:
Expand Down
64 changes: 64 additions & 0 deletions gpio/readall.c
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,60 @@ static int physToWpi_5MAX[64] =
-1, -1, -1, -1, -1, -1, -1, // ... 63
};

static int physToWpi_5PRO[64] =
{
-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
19, -1, //29,30
20, 21, //31,32
22, -1, //33,34
23, 24, //35,36
25, 26, //37,38
-1, 27, //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
};

static char * physNames_5PRO[64] =
{
NULL,
" 3.3V", "5V ",
" SDA.1", "5V ",
" SCL.1", "GND ",
" PWM13", "TXD.2 ",
" GND", "RXD.2 ",
" CAN1_RX", "GPIO1_A7",
" CAN1_TX", "GND ",
"GPIO1_B6", "TXD.6 ",
" 3.3V", "RXD.6 ",
"SPI0_TXD", "GND ",
"SPI0_RXD", "GPIO1_B0",
"SPI0_CLK", "SPI0_CS0",
" GND", "SPI0_CS1",
" SDA.4", "SCL.4 ",
"GPIO1_A4", "GND ",
"GPIO1_A6", "PWM14 ",
" PWM15", "GND ",
"GPIO4_A7", "TXD.0 ",
"GPIO4_A6", "RXD.0 ",
" GND", "GPIO4_A5",
};

static char * physNames_5PLUS[64] =
{
NULL,
Expand Down Expand Up @@ -1555,6 +1609,12 @@ void OrangePiReadAll(int model)
physNames = physNames_5B;
alts = alts_rk3588;
break;
case PI_MODEL_5_PRO:
printf (" +------+-----+----------+--------+---+ PI5 PRO +---+--------+----------+-----+------+\n");
physToWpi = physToWpi_5PRO;
physNames = physNames_5PRO;
alts = alts_rk3588;
break;
case PI_MODEL_5_MAX:
printf (" +------+-----+----------+--------+---+ PI5 MAX +---+--------+----------+-----+------+\n");
physToWpi = physToWpi_5MAX;
Expand Down Expand Up @@ -1607,6 +1667,7 @@ void OrangePiReadAll(int model)
case PI_MODEL_PC_2:
case PI_MODEL_PRIME:
case PI_MODEL_WIN:
case PI_MODEL_5_PRO:
case PI_MODEL_5_MAX:
case PI_MODEL_5_PLUS:
case PI_MODEL_900:
Expand Down Expand Up @@ -1701,6 +1762,9 @@ void OrangePiReadAll(int model)
case PI_MODEL_5B:
printf (" +------+-----+----------+--------+---+ PI5B +---+--------+----------+-----+------+\n");
break;
case PI_MODEL_5_PRO:
printf (" +------+-----+----------+--------+---+ PI5 PRO +---+--------+----------+-----+------+\n");
break;
case PI_MODEL_5_MAX:
printf (" +------+-----+----------+--------+---+ PI5 MAX +---+--------+----------+-----+------+\n");
break;
Expand Down
86 changes: 84 additions & 2 deletions wiringPi/wiringPi.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,15 @@ static int ORANGEPI_PIN_MASK_5B[5][32] = //[BANK] [INDEX]
{-1,-1,-1, 3, 4,-1,-1,-1, -1,-1, 2, 3, 4,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,},//GPIO4
};

static int ORANGEPI_PIN_MASK_5PRO[5][32] = //[BANK] [INDEX]
{
{-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1, 5, 6,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,},//GPIO0
{ 0, 1, 2, 3, 4,-1, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1, 2, 3,-1,-1, 6, 7,},//GPIO1
{-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,},//GPIO2
{-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,},//GPIO3
{-1,-1,-1, 3, 4, 5, 6, 7, -1,-1, 2, 3,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,},//GPIO4
};

static int ORANGEPI_PIN_MASK_5MAX[5][32] = //[BANK] [INDEX]
{
{-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1, 5, 6, 7, 0,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,},//GPIO0
Expand Down Expand Up @@ -937,6 +946,29 @@ int pinToGpio_5B[64] =
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,// ... 63
};

int pinToGpio_5PRO[64] =
{
59, 58, // 0, 1
47, 13, // 2, 3
14, 138, // 4 5
39, 139, // 6, 7
46, 33, // 8, 9
32, 42, //10,11
41, 40, //12,13
43, 44, //14,15
45, 34, //16,17
35, 36, //18,19
38, 62, //20,21
63, 135, //22,23
131,134, //24,25
132,133, //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 pinToGpio_5MAX[64] =
{
16, 15, // 0, 1
Expand Down Expand Up @@ -1557,6 +1589,35 @@ int physToGpio_5B[64] =
-1, -1, -1, -1, -1, -1, -1, // ... 63
};

int physToGpio_5PRO[64] =
{
-1, // 0
-1, -1, // 1, 2
59, -1, // 3, 4
58, -1, // 5, 6
47, 13, // 7, 8
-1, 14, // 9, 10
138, 39, // 11, 12
139, -1, // 13, 14
46, 33, // 15, 16
-1, 32, // 17, 18
42, -1, // 19, 20
41, 40, // 21, 22
43, 44, // 23, 24
-1, 45, // 25, 26
34, 35, // 27, 28
36, -1, // 29, 30
38, 62, // 31, 32
63, -1, // 33, 34
135,131, // 35, 36
134,132, // 37, 38
-1, 133, // 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 physToGpio_5MAX[64] =
{
-1, // 0
Expand Down Expand Up @@ -2097,6 +2158,8 @@ void piBoardId (int * model)
else if (strncmp(revision, "orangepi-r1plus-lts.", 20) == 0) { *model = PI_MODEL_R1_PLUS; }
else if (strncmp(revision, "orangepi5.", 10) == 0) { *model = PI_MODEL_5; }
else if (strncmp(revision, "orangepi5b.", 11) == 0) { *model = PI_MODEL_5B; }
else if (strncmp(revision, "orangepi5pro.", 13) == 0) { *model = PI_MODEL_5_PRO; }
else if (strncmp(revision, "orangepi5max.", 13) == 0) { *model = PI_MODEL_5_MAX; }
else if (strncmp(revision, "orangepi5plus.", 14) == 0) { *model = PI_MODEL_5_PLUS; }
else if (strncmp(revision, "orangepi900.", 12) == 0) { *model = PI_MODEL_900; }
else if (strncmp(revision, "orangepicm4.", 12) == 0) { *model = PI_MODEL_CM4; }
Expand Down Expand Up @@ -2330,6 +2393,8 @@ void sunxi_pwm_set_tone(int pin,int freq)
{
case PI_MODEL_5:
case PI_MODEL_5B:
case PI_MODEL_5_PRO:
case PI_MODEL_5_MAX:
case PI_MODEL_5_PLUS:

rk3588_set_pwm_reg(pin,&rk3588_soc_info_t);
Expand Down Expand Up @@ -2514,6 +2579,8 @@ void sunxi_pwm_set_clk(int pin,int clk)
{
case PI_MODEL_5:
case PI_MODEL_5B:
case PI_MODEL_5_PRO:
case PI_MODEL_5_MAX:
case PI_MODEL_5_PLUS:

if ((clk < 2) || (clk > 512)) {
Expand Down Expand Up @@ -2716,6 +2783,8 @@ void sunxi_pwm_set_period(int pin,unsigned int period_cys)
{
case PI_MODEL_5:
case PI_MODEL_5B:
case PI_MODEL_5_PRO:
case PI_MODEL_5_MAX:
case PI_MODEL_5_PLUS:

rk3588_set_pwm_reg(pin,&rk3588_soc_info_t);
Expand Down Expand Up @@ -2855,6 +2924,8 @@ void sunxi_pwm_set_act(int pin,int act_cys)
{
case PI_MODEL_5:
case PI_MODEL_5B:
case PI_MODEL_5_PRO:
case PI_MODEL_5_MAX:
case PI_MODEL_5_PLUS:

rk3588_set_pwm_reg(pin,&rk3588_soc_info_t);
Expand Down Expand Up @@ -4245,6 +4316,11 @@ int wiringPiSetup (void)
physToGpio = physToGpio_5B;
ORANGEPI_PIN_MASK = ORANGEPI_PIN_MASK_5B;
break;
case PI_MODEL_5_PRO:
pinToGpio = pinToGpio_5PRO;
physToGpio = physToGpio_5PRO;
ORANGEPI_PIN_MASK = ORANGEPI_PIN_MASK_5PRO;
break;
case PI_MODEL_5_MAX:
pinToGpio = pinToGpio_5MAX;
physToGpio = physToGpio_5MAX;
Expand Down Expand Up @@ -4367,7 +4443,7 @@ int wiringPiSetup (void)

break;

case PI_MODEL_5: case PI_MODEL_5B: case PI_MODEL_5_MAX: case PI_MODEL_5_PLUS: case PI_MODEL_900:
case PI_MODEL_5: case PI_MODEL_5B: case PI_MODEL_5_PRO: case PI_MODEL_5_MAX: case PI_MODEL_5_PLUS: case PI_MODEL_900:

/* GPIO Register */
rk3588_soc_info_t.gpio0_base = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, RK3588_GPIO0_BASE);
Expand Down Expand Up @@ -4693,6 +4769,7 @@ unsigned int readR(unsigned int addr)
switch (OrangePiModel)
{
case PI_MODEL_5: case PI_MODEL_5B:
case PI_MODEL_5_PRO:
case PI_MODEL_5_MAX:
case PI_MODEL_5_PLUS:
case PI_MODEL_900:
Expand Down Expand Up @@ -4883,6 +4960,7 @@ void writeR(unsigned int val, unsigned int addr)
switch (OrangePiModel)
{
case PI_MODEL_5: case PI_MODEL_5B:
case PI_MODEL_5_PRO:
case PI_MODEL_5_MAX:
case PI_MODEL_5_PLUS:
case PI_MODEL_900:
Expand Down Expand Up @@ -5083,6 +5161,7 @@ int OrangePi_get_gpio_mode(int pin)
break;

case PI_MODEL_5: case PI_MODEL_5B:
case PI_MODEL_5_PRO:
case PI_MODEL_5_MAX:
case PI_MODEL_5_PLUS:
case PI_MODEL_900:
Expand Down Expand Up @@ -5550,7 +5629,7 @@ int OrangePi_set_gpio_mode(int pin, int mode)
switch (OrangePiModel)
{
case PI_MODEL_5: case PI_MODEL_5B:
case PI_MODEL_5_MAX:
case PI_MODEL_5_PRO:
case PI_MODEL_5_PLUS:
case PI_MODEL_900:

Expand Down Expand Up @@ -6399,6 +6478,7 @@ int OrangePi_digitalWrite(int pin, int value)
switch (OrangePiModel)
{
case PI_MODEL_5: case PI_MODEL_5B:
case PI_MODEL_5_PRO:
case PI_MODEL_5_MAX:
case PI_MODEL_5_PLUS:
case PI_MODEL_900:
Expand Down Expand Up @@ -6705,6 +6785,7 @@ int OrangePi_digitalRead(int pin)
switch (OrangePiModel)
{
case PI_MODEL_5: case PI_MODEL_5B:
case PI_MODEL_5_PRO:
case PI_MODEL_5_MAX:
case PI_MODEL_5_PLUS:
case PI_MODEL_900:
Expand Down Expand Up @@ -6809,6 +6890,7 @@ void OrangePi_set_gpio_pullUpDnControl (int pin, int pud)
switch (OrangePiModel)
{
case PI_MODEL_5: case PI_MODEL_5B:
case PI_MODEL_5_PRO:
case PI_MODEL_5_MAX:
case PI_MODEL_5_PLUS:
case PI_MODEL_900:
Expand Down
4 changes: 2 additions & 2 deletions wiringPi/wiringPi.h
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,8 @@ extern int wiringPiDebug;
#define PI_MODEL_900 23
#define PI_MODEL_5 24
#define PI_MODEL_5B 25
#define PI_MODEL_5PRO 26
#define PI_MODEL_5MAX 27
#define PI_MODEL_5_PRO 26
#define PI_MODEL_5_MAX 27
#define PI_MODEL_5_PLUS 28

/* Rockchip RK3566 */
Expand Down

0 comments on commit 08a843c

Please sign in to comment.