Skip to content

Commit

Permalink
Support Orange Pi 3B
Browse files Browse the repository at this point in the history
  • Loading branch information
baiywt committed Jul 18, 2023
1 parent 1558d46 commit fbd2b76
Show file tree
Hide file tree
Showing 4 changed files with 27 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 @@ -33,6 +33,7 @@ unsigned char getGpioNum(void)
case PI_MODEL_4:
case PI_MODEL_5_PLUS:
case PI_MODEL_CM4:
case PI_MODEL_3B:
case PI_MODEL_ZERO_2_W:
return 28;
break;
Expand Down
19 changes: 15 additions & 4 deletions gpio/readall.c
Original file line number Diff line number Diff line change
Expand Up @@ -1070,19 +1070,19 @@ static char * physNames_CM4[64] =
" 3.3V", "5V ",
" SDA.2", "5V ",
" SCL.2", "GND ",
"GPIO4_A4", "RXD.2 ",
" TXD.9", "RXD.2 ",
" GND", "TXD.2 ",
"GPIO3_C6", "GPIO3_C7",
"GPIO4_A0", "GND ",
"GPIO4_A2", "GPIO4_A3",
" TXD.7", "RXD.7 ",
" 3.3V", "GPIO4_A1",
"SPI3_TXD", "GND ",
"SPI3_RXD", "GPIO4_B1",
"SPI3_CLK", "SPI3_CS1",
" GND", "GPIO4_A7",
" SDA.3", "SCL.3 ",
"GPIO4_A5", "GND ",
"GPIO3_D4", "GPIO4_C0",
" RXD.9", "GND ",
"GPIO3_D4", "PWM11 ",
"GPIO3_D7", "GND ",
"GPIO3_D0", "GPIO3_D5",
"GPIO3_D3", "GPIO3_D2",
Expand Down Expand Up @@ -1404,6 +1404,13 @@ void OrangePiReadAll(int model)
physNames = physNames_CM4;
alts = alts_rk3588;
break;
case PI_MODEL_3B:
printf (" +------+-----+----------+--------+---+ PI3B +---+--------+----------+-----+------+\n");
physToWpi = physToWpi_CM4;
physNames = physNames_CM4;
alts = alts_rk3588;
break;

default:
printf ("Oops - unable to determine board type... model: %d\n", model);
break ;
Expand All @@ -1422,6 +1429,7 @@ void OrangePiReadAll(int model)
case PI_MODEL_WIN:
case PI_MODEL_5_PLUS:
case PI_MODEL_CM4:
case PI_MODEL_3B:
case PI_MODEL_ZERO_2_W:
for (pin = 1 ; pin <= 40; pin += 2)
readallPhys(pin);
Expand Down Expand Up @@ -1516,6 +1524,9 @@ void OrangePiReadAll(int model)
case PI_MODEL_CM4:
printf (" +------+-----+----------+--------+---+ PI CM4 +---+--------+----------+-----+------+\n");
break;
case PI_MODEL_3B:
printf (" +------+-----+----------+--------+---+ PI3B +---+--------+----------+-----+------+\n");
break;
default:
printf ("Oops - unable to determine board type... model: %d\n", model);
break ;
Expand Down
10 changes: 10 additions & 0 deletions wiringPi/wiringPi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1885,6 +1885,7 @@ void piBoardId (int * model)
else if (strncmp(revision, "orangepi5b.", 11) == 0) { *model = PI_MODEL_5B; }
else if (strncmp(revision, "orangepi5plus.", 14) == 0) { *model = PI_MODEL_5_PLUS; }
else if (strncmp(revision, "orangepicm4.", 12) == 0) { *model = PI_MODEL_CM4; }
else if (strncmp(revision, "orangepi3b.", 11) == 0) { *model = PI_MODEL_3B; }

if (wiringPiDebug)
printf("piBoardId: model = %d\n", *model);
Expand Down Expand Up @@ -3122,6 +3123,7 @@ int wiringPiSetup (void)
ORANGEPI_PIN_MASK = ORANGEPI_PIN_MASK_5PLUS;
break;
case PI_MODEL_CM4:
case PI_MODEL_3B:
pinToGpio = pinToGpio_CM4;
physToGpio = physToGpio_CM4;
ORANGEPI_PIN_MASK = ORANGEPI_PIN_MASK_CM4;
Expand Down Expand Up @@ -3277,6 +3279,7 @@ int wiringPiSetup (void)
break;

case PI_MODEL_CM4:
case PI_MODEL_3B:

/* GPIO Register */
rk3566_soc_info_t.gpio0_base = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, RK3566_GPIO0_BASE);
Expand Down Expand Up @@ -3581,6 +3584,7 @@ unsigned int readR(unsigned int addr)
break;

case PI_MODEL_CM4:
case PI_MODEL_3B:

val = 0;

Expand Down Expand Up @@ -3712,6 +3716,7 @@ void writeR(unsigned int val, unsigned int addr)
break;

case PI_MODEL_CM4:
case PI_MODEL_3B:

mmap_base = (addr & (~0xfff));
mmap_seek = (addr - mmap_base);
Expand Down Expand Up @@ -3894,6 +3899,7 @@ int OrangePi_get_gpio_mode(int pin)
break;

case PI_MODEL_CM4:
case PI_MODEL_3B:

if(bank == 0){
grf_phyaddr = RK3566_PMU_GRF_BASE + RK3566_PMU_GRF_GPIO0A_IOMUX_L_OFFSET + ((pin >> 2) << 2);
Expand Down Expand Up @@ -4234,6 +4240,7 @@ int OrangePi_set_gpio_mode(int pin, int mode)
break;

case PI_MODEL_CM4:
case PI_MODEL_3B:
if(bank == 0){
cru_phyaddr = RK3566_PMU_CRU_BASE + RK3566_PMUCRU_PMUGATE_CON01_OFFSET;
cru_val = ~((0x3 << 9) | (0x3 << (16 + 9)));
Expand Down Expand Up @@ -4558,6 +4565,7 @@ int OrangePi_digitalWrite(int pin, int value)
break;

case PI_MODEL_CM4:
case PI_MODEL_3B:

if(bank == 0){
dr_phyaddr = RK3566_GPIO0_BASE + RK3566_GPIO_SWPORT_DR_L_OFFSET + ((index >> 4) << 2);
Expand Down Expand Up @@ -4703,6 +4711,7 @@ int OrangePi_digitalRead(int pin)
break;

case PI_MODEL_CM4:
case PI_MODEL_3B:

if(bank == 0)
phyaddr = RK3566_GPIO0_BASE + RK3566_GPIO_EXT_PORT_OFFSET;
Expand Down Expand Up @@ -4813,6 +4822,7 @@ void OrangePi_set_gpio_pullUpDnControl (int pin, int pud)
break;

case PI_MODEL_CM4:
case PI_MODEL_3B:

if (bank == 0)
phyaddr = RK3566_PMU_GRF_BASE + RK3566_PMU_GRF_GPIO0A_P_OFFSET + (((pin - 0) >> 3) << 2);
Expand Down
1 change: 1 addition & 0 deletions wiringPi/wiringPi.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ extern int wiringPiDebug;

/* Rockchip RK3566 */
#define PI_MODEL_CM4 27
#define PI_MODEL_3B 28

extern const char *piModelNames [16] ;

Expand Down

0 comments on commit fbd2b76

Please sign in to comment.