Skip to content

Commit

Permalink
Support Orange Pi 5 Ultra
Browse files Browse the repository at this point in the history
  • Loading branch information
leeboby committed Jul 22, 2024
1 parent 535efb3 commit 3a0b917
Show file tree
Hide file tree
Showing 4 changed files with 149 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 @@ -40,6 +40,7 @@ unsigned char getGpioNum(void)
case PI_MODEL_4:
case PI_MODEL_5_PRO:
case PI_MODEL_5_MAX:
case PI_MODEL_5_ULTRA:
case PI_MODEL_5_PLUS:
case PI_MODEL_900:
case PI_MODEL_CM4:
Expand Down
64 changes: 64 additions & 0 deletions gpio/readall.c
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,60 @@ static int physToWpi_5MAX[64] =
-1, -1, -1, -1, -1, -1, -1, // ... 63
};

static char * physNames_5ULTRA[64] =
{
NULL,
" 3.3V", "5V ",
" SDA.2", "5V ",
" SCL.2", "GND ",
" PWM3", "TXD.2 ",
" GND", "RXD.2 ",
" RXD.6", "GPIO4_A6",
" TXD.6", "GND ",
"GPIO1_A2", "GPIO1_A3",
" 3.3V", "GPIO1_A4",
"SPI0_TXD", "GND ",
"SPI0_RXD", "GPIO1_B0",
"SPI0_CLK", "SPI0_CS0",
" GND", "SPI0_CS1",
" SDA.8", "SCL.8 ",
"GPIO3_C1", "GND ",
" CAN1_RX", "GPIO4_B3",
" CAN1_TX", "GND ",
"GPIO3_C2", "GPIO4_B7",
"GPIO4_A7", "GPIO3_C0",
" GND", "GPIO3_B7",
};

static int physToWpi_5ULTRA[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 int physToWpi_5PRO[64] =
{
-1, //0
Expand Down Expand Up @@ -1817,6 +1871,12 @@ void OrangePiReadAll(int model)
physNames = physNames_5MAX;
alts = alts_rk3588;
break;
case PI_MODEL_5_ULTRA:
printf (" +------+-----+----------+--------+---+OPI5-ULTAR+---+--------+----------+-----+------+\n");
physToWpi = physToWpi_5ULTRA;
physNames = physNames_5ULTRA;
alts = alts_rk3588;
break;
case PI_MODEL_5_PLUS:
printf (" +------+-----+----------+--------+---+ PI5 PLUS +---+--------+----------+-----+------+\n");
physToWpi = physToWpi_5PLUS;
Expand Down Expand Up @@ -1892,6 +1952,7 @@ void OrangePiReadAll(int model)
case PI_MODEL_WIN:
case PI_MODEL_5_PRO:
case PI_MODEL_5_MAX:
case PI_MODEL_5_ULTRA:
case PI_MODEL_5_PLUS:
case PI_MODEL_900:
case PI_MODEL_CM4:
Expand Down Expand Up @@ -1997,6 +2058,9 @@ void OrangePiReadAll(int model)
case PI_MODEL_5_MAX:
printf (" +------+-----+----------+--------+---+ PI5 MAX +---+--------+----------+-----+------+\n");
break;
case PI_MODEL_5_ULTRA:
printf (" +------+-----+----------+--------+---+OPI5-ULTAR+---+--------+----------+-----+------+\n");
break;
case PI_MODEL_5_PLUS:
printf (" +------+-----+----------+--------+---+ PI5 PLUS +---+--------+----------+-----+------+\n");
break;
Expand Down
79 changes: 79 additions & 0 deletions wiringPi/wiringPi.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,15 @@ static int ORANGEPI_PIN_MASK_5MAX[5][32] = //[BANK] [INDEX]
{-1,-1,-1,-1,-1,-1, 6, 7, -1,-1,-1,-1,-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_5ULTRA[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
{ 0, 1, 2, 3, 4,-1,-1, 7, 0, 1, 2, 3, 4, 5, 6, 7, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-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, 5, 6, 7, 0, 1, 2,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,},//GPIO3
{-1,-1,-1,-1,-1,-1, 6, 7, -1,-1,-1, 3,-1,-1,-1, 7, 0, 1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,},//GPIO4
};

static int ORANGEPI_PIN_MASK_5PLUS[5][32] = //[BANK] [INDEX]
{
{-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, 7, 0,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,},//GPIO0
Expand Down Expand Up @@ -1079,6 +1088,29 @@ int pinToGpio_5MAX[64] =
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,// ... 63
};

int pinToGpio_5ULTRA[64] =
{
16, 15, // 0, 1
39, 13, // 2, 3
14, 32, // 4 5
134, 33, // 6, 7
34, 35, // 8, 9
36, 42, //10,11
41, 40, //12,13
43, 44, //14,15
45, 145, //16,17
144,113, //18,19
109,139, //20,21
110,114, //22,23
143,135, //24,25
112,111, //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_5PLUS[64] =
{
16, 15, // 0, 1
Expand Down Expand Up @@ -1838,6 +1870,35 @@ int physToGpio_5MAX[64] =
-1, -1, -1, -1, -1, -1, -1, // ... 63
};

int physToGpio_5ULTRA[64] =
{
-1, // 0
-1, -1, // 1, 2
16, -1, // 3, 4
15, -1, // 5, 6
39, 13, // 7, 8
-1, 14, // 9, 10
32, 134, // 11, 12
33, -1, // 13, 14
34, 35, // 15, 16
-1, 36, // 17, 18
42, -1, // 19, 20
41, 40, // 21, 22
43, 44, // 23, 24
-1, 45, // 25, 26
145,144, // 27, 28
113, -1, // 29, 30
109,139, // 31, 32
110, -1, // 33, 34
114,143, // 35, 36
135,112, // 37, 38
-1, 111, // 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_5PLUS[64] =
{
-1, // 0
Expand Down Expand Up @@ -2410,6 +2471,7 @@ void piBoardId (int * model)
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, "orangepi5ultra.", 15) == 0) { *model = PI_MODEL_5_ULTRA; }
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, "orangepicm5.", 12) == 0) { *model = PI_MODEL_CM5; }
Expand Down Expand Up @@ -2654,6 +2716,7 @@ void orangepi_pwm_set_tone(int pin,int freq)
case PI_MODEL_CM5_TABLET:
case PI_MODEL_5_PRO:
case PI_MODEL_5_MAX:
case PI_MODEL_5_ULTRA:
case PI_MODEL_5_PLUS:

rk3588_set_pwm_reg(pin,&rk3588_soc_info_t);
Expand Down Expand Up @@ -2880,6 +2943,7 @@ void orangepi_pwm_set_clk(int pin,int clk)
case PI_MODEL_CM5_TABLET:
case PI_MODEL_5_PRO:
case PI_MODEL_5_MAX:
case PI_MODEL_5_ULTRA:
case PI_MODEL_5_PLUS:

if ((clk < 2) || (clk > 512)) {
Expand Down Expand Up @@ -3100,6 +3164,7 @@ void orangepi_pwm_set_period(int pin,unsigned int period_cys)
case PI_MODEL_CM5_TABLET:
case PI_MODEL_5_PRO:
case PI_MODEL_5_MAX:
case PI_MODEL_5_ULTRA:
case PI_MODEL_5_PLUS:

rk3588_set_pwm_reg(pin,&rk3588_soc_info_t);
Expand Down Expand Up @@ -3262,6 +3327,7 @@ void orangepi_pwm_set_act(int pin, int act_cys)
case PI_MODEL_CM5_TABLET:
case PI_MODEL_5_PRO:
case PI_MODEL_5_MAX:
case PI_MODEL_5_ULTRA:
case PI_MODEL_5_PLUS:

rk3588_set_pwm_reg(pin,&rk3588_soc_info_t);
Expand Down Expand Up @@ -4702,6 +4768,11 @@ int wiringPiSetup (void)
physToGpio = physToGpio_5MAX;
ORANGEPI_PIN_MASK = ORANGEPI_PIN_MASK_5MAX;
break;
case PI_MODEL_5_ULTRA:
pinToGpio = pinToGpio_5ULTRA;
physToGpio = physToGpio_5ULTRA;
ORANGEPI_PIN_MASK = ORANGEPI_PIN_MASK_5ULTRA;
break;
case PI_MODEL_5_PLUS:
pinToGpio = pinToGpio_5PLUS;
physToGpio = physToGpio_5PLUS;
Expand Down Expand Up @@ -4831,6 +4902,7 @@ int wiringPiSetup (void)
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:
case PI_MODEL_CM5:
case PI_MODEL_CM5_TABLET:
case PI_MODEL_5_ULTRA:

/* 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 @@ -5239,6 +5311,7 @@ unsigned int readR(unsigned int addr)
case PI_MODEL_5: case PI_MODEL_5B:
case PI_MODEL_5_PRO:
case PI_MODEL_5_MAX:
case PI_MODEL_5_ULTRA:
case PI_MODEL_5_PLUS:
case PI_MODEL_900:
case PI_MODEL_CM5:
Expand Down Expand Up @@ -5468,6 +5541,7 @@ void writeR(unsigned int val, unsigned int addr)
case PI_MODEL_5: case PI_MODEL_5B:
case PI_MODEL_5_PRO:
case PI_MODEL_5_MAX:
case PI_MODEL_5_ULTRA:
case PI_MODEL_5_PLUS:
case PI_MODEL_900:
case PI_MODEL_CM5:
Expand Down Expand Up @@ -5716,6 +5790,7 @@ int orangepi_get_gpio_mode(int pin)
case PI_MODEL_5: case PI_MODEL_5B:
case PI_MODEL_5_PRO:
case PI_MODEL_5_MAX:
case PI_MODEL_5_ULTRA:
case PI_MODEL_5_PLUS:
case PI_MODEL_900:
case PI_MODEL_CM5:
Expand Down Expand Up @@ -6307,6 +6382,7 @@ int orangepi_set_gpio_mode(int pin, int mode)
case PI_MODEL_5: case PI_MODEL_5B:
case PI_MODEL_5_PRO:
case PI_MODEL_5_MAX:
case PI_MODEL_5_ULTRA:
case PI_MODEL_5_PLUS:
case PI_MODEL_900:
case PI_MODEL_CM5:
Expand Down Expand Up @@ -7326,6 +7402,7 @@ int orangepi_digitalWrite(int pin, int value)
case PI_MODEL_5: case PI_MODEL_5B:
case PI_MODEL_5_PRO:
case PI_MODEL_5_MAX:
case PI_MODEL_5_ULTRA:
case PI_MODEL_5_PLUS:
case PI_MODEL_900:
case PI_MODEL_CM5:
Expand Down Expand Up @@ -7692,6 +7769,7 @@ int orangepi_digitalRead(int pin)
case PI_MODEL_5: case PI_MODEL_5B:
case PI_MODEL_5_PRO:
case PI_MODEL_5_MAX:
case PI_MODEL_5_ULTRA:
case PI_MODEL_5_PLUS:
case PI_MODEL_900:
case PI_MODEL_CM5:
Expand Down Expand Up @@ -7825,6 +7903,7 @@ void OrangePi_set_gpio_pullUpDnControl (int pin, int pud)
case PI_MODEL_5: case PI_MODEL_5B:
case PI_MODEL_5_PRO:
case PI_MODEL_5_MAX:
case PI_MODEL_5_ULTRA:
case PI_MODEL_5_PLUS:
case PI_MODEL_900:
case PI_MODEL_CM5:
Expand Down
9 changes: 5 additions & 4 deletions wiringPi/wiringPi.h
Original file line number Diff line number Diff line change
Expand Up @@ -749,16 +749,17 @@ extern int wiringPiDebug;
#define PI_MODEL_5_PLUS 28
#define PI_MODEL_CM5 29
#define PI_MODEL_CM5_TABLET 39
#define PI_MODEL_5_ULTRA 40

/* Rockchip RK3566 */
#define PI_MODEL_CM4 40
#define PI_MODEL_3B 41
#define PI_MODEL_CM4 50
#define PI_MODEL_3B 51

/* S905D3 */
#define PI_MODEL_3_PLUS 50
#define PI_MODEL_3_PLUS 60

/* Ascend 310B */
#define PI_MODEL_AI_PRO 51
#define PI_MODEL_AI_PRO 70

extern const char *piModelNames [16] ;

Expand Down

0 comments on commit 3a0b917

Please sign in to comment.