Skip to content

Commit

Permalink
adding support for Orin AGX
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubberazer committed Jun 23, 2024
1 parent f982852 commit 7901323
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 50 deletions.
39 changes: 13 additions & 26 deletions orin.c
Original file line number Diff line number Diff line change
Expand Up @@ -2128,8 +2128,13 @@ int gpioSetPWMfrequency(unsigned gpio, unsigned frequency) {
printf( "Not possible to change clock rate on pwm1\n");
}
fclose(fptr);
*pinmux15 = 0x00000400;
*pincfg15 = CFGO_OUT;
pin15->CNF[0] = 0x00000001;
*PWM1 = 0x0;
*PWM1 = PFM;
pin_tracker |= (1 << 28);
break;

case 32:
snprintf(buf, sizeof(buf), "/sys/kernel/debug/bpmp/debug/clk/pwm7/rate");
fptr = fopen(buf, "r");
Expand All @@ -2145,6 +2150,12 @@ int gpioSetPWMfrequency(unsigned gpio, unsigned frequency) {
printf( "Not possible to change clock rate on pwm7\n");
}
fclose(fptr);
*pinmux32 = 0x00000400;
*pincfg32 = CFGO_OUT;
pin32->CNF[0] = 0x00000001;
*PWM7 = 0x0;
*PWM7 = PFM;
pin_tracker |= (1 << 30);
break;
case 33:
snprintf(buf, sizeof(buf), "/sys/kernel/debug/bpmp/debug/clk/pwm5/rate");
Expand All @@ -2161,30 +2172,6 @@ int gpioSetPWMfrequency(unsigned gpio, unsigned frequency) {
printf( "Not possible to change clock rate on pwm5\n");
}
fclose(fptr);
break;
default:
status = -1;
printf("Only gpio numbers 15, 32 and 33 are accepted\n");
}

switch (gpio) {
case 15:
*pinmux15 = 0x00000400;
*pincfg15 = CFGO_OUT;
pin15->CNF[0] = 0x00000001;
*PWM1 = 0x0;
*PWM1 = PFM;
pin_tracker |= (1 << 28);
break;
case 32:
*pinmux32 = 0x00000400;
*pincfg32 = CFGO_OUT;
pin32->CNF[0] = 0x00000001;
*PWM7 = 0x0;
*PWM7 = PFM;
pin_tracker |= (1 << 30);
break;
case 33:
*pinmux33 = 0x00000401;
*pincfg33 = CFGO_OUT;
pin33->CNF[0] = 0x00000001;
Expand All @@ -2195,7 +2182,7 @@ int gpioSetPWMfrequency(unsigned gpio, unsigned frequency) {
default:
status = -1;
printf("Only gpio numbers 15, 32 and 33 are accepted\n");
}
}
}
else {printf("Only frequencies from 50 to 1595000 Hz are allowed\n");
status =-2;}
Expand Down
37 changes: 13 additions & 24 deletions orinagx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2137,6 +2137,12 @@ int gpioSetPWMfrequency(unsigned gpio, unsigned frequency) {
printf( "Not possible to change clock rate on pwm8\n");
}
fclose(fptr);
*pinmux13 = 0x00000400;
*pincfg13 = CFGO_OUT;
pin13->CNF[0] = 0x00000001;
*PWM8 = 0x0;
*PWM8 = PFM;
pin_tracker |= (1 << 30);
break;
case 15:
snprintf(buf, sizeof(buf), "/sys/kernel/debug/bpmp/debug/clk/pwm1/rate");
Expand All @@ -2153,6 +2159,12 @@ int gpioSetPWMfrequency(unsigned gpio, unsigned frequency) {
printf( "Not possible to change clock rate on pwm1\n");
}
fclose(fptr);
*pinmux15 = 0x00000400;
*pincfg15 = CFGO_OUT;
pin15->CNF[0] = 0x00000001;
*PWM1 = 0x0;
*PWM1 = PFM;
pin_tracker |= (1 << 28);
break;
case 18:
snprintf(buf, sizeof(buf), "/sys/kernel/debug/bpmp/debug/clk/pwm5/rate");
Expand All @@ -2169,29 +2181,6 @@ int gpioSetPWMfrequency(unsigned gpio, unsigned frequency) {
printf( "Not possible to change clock rate on pwm5\n");
}
fclose(fptr);
break;
default:
status = -1;
printf("Only gpio numbers 13, 15 and 18 are accepted\n");
}
switch (gpio) {
case 13:
*pinmux13 = 0x00000400;
*pincfg13 = CFGO_OUT;
pin13->CNF[0] = 0x00000001;
*PWM8 = 0x0;
*PWM8 = PFM;
pin_tracker |= (1 << 30);
break;
case 15:
*pinmux15 = 0x00000400;
*pincfg15 = CFGO_OUT;
pin15->CNF[0] = 0x00000001;
*PWM1 = 0x0;
*PWM1 = PFM;
pin_tracker |= (1 << 28);
break;
case 18:
*pinmux18 = 0x00000401;
*pincfg18 = CFGO_OUT;
pin18->CNF[0] = 0x00000001;
Expand All @@ -2202,7 +2191,7 @@ int gpioSetPWMfrequency(unsigned gpio, unsigned frequency) {
default:
status = -1;
printf("Only gpio numbers 13, 15 and 18 are accepted\n");
}
}
}
else {printf("Only frequencies from 50 to 1595000 Hz are allowed\n");
status =-2;}
Expand Down

0 comments on commit 7901323

Please sign in to comment.