What is name of gpio hardware on a rock64?
#1
The driver code checks for it, and will return a valid answer if its a bcm2709, bcm2835, bcm2836, or a bcm2837. Code is:
Code:
#define CPUINFO_BUFSIZE (16*1024) // Should be large enough for now
static platform_t check_platform(void)
{
FILE *fp;
char *buf;
size_t fsize;
platform_t rv = RPI_UNSUPPORTED;

if(!(buf = rtapi_kmalloc(CPUINFO_BUFSIZE, RTAPI_GFP_KERNEL))) {
rtapi_print_msg(RPSPI_ERR, "hm2_rpspi: No dynamic memory\n");
return RPI_UNSUPPORTED;
}
if(!(fp = fopen("/proc/cpuinfo", "r"))) {
rtapi_print_msg(RPSPI_ERR, "hm2_rpspi: Failed to open /proc/cpuinfo\n");
goto check_exit;
}
fsize = fread(buf, 1, CPUINFO_BUFSIZE - 1, fp);
fclose(fp);

// we have truncated cpuinfo return unsupported
if(!fsize || fsize == CPUINFO_BUFSIZE - 1) {
rtapi_print_msg(RPSPI_ERR, "hm2_rpspi: Platform detection memory buffer too small\n");
goto check_exit;
}

/* NUL terminate the buffer */
buf[fsize] = '\0';

if(strstr(buf, "BCM2708")) {
rv = RPI_1;
} else if(strstr(buf, "BCM2709")) {
rv = RPI_2; //for RPI 3 too
} else if(strstr(buf, "BCM2835")) { // starting with 4.8 kernels revision tag has board details
char *rev_val = strstr(buf, "Revision");
if(rev_val) {
char *rev_start = strstr(rev_val, ": ");
unsigned long rev = strtol(rev_start + 2, NULL, 16);

if(rev <= 0xffff)
rv = RPI_1; // pre pi2 revision scheme
else {
switch((rev & 0xf000) >> 12) {
case 0: //bcm2835
rv = RPI_1;
break;
case 1: //bcm2836
case 2: //bcm2837
rv = RPI_2; // peripheral base is same on pi2/3
break;
default:
break;
}
}
}
}

check_exit:
rtapi_kfree(buf);
return rv;
}

And all the c style indenting has been stripped, so how do I post code?  This sucks.



Thanks everybody.

Cheers, Gene83
  Reply


Messages In This Thread
What is name of gpio hardware on a rock64? - by gene83 - 10-04-2017, 12:04 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  openwrt for the rock64 wilsonYan 8 2,514 01-16-2021, 11:16 PM
Last Post: chainu127
  Linux Images (ROCK64) pineadmin 163 122,613 01-05-2021, 10:43 AM
Last Post: DuckyBoi
  slarm64 (unofficial slackware) Rock64 RK3328 (aarch64) mara 100 41,430 12-28-2020, 11:39 AM
Last Post: mara
  Armbian for Rock64 pineadmin 26 14,495 12-25-2020, 11:07 PM
Last Post: lanefu
  DietPi OS for ROCK64 MichaIng 9 838 12-22-2020, 03:25 PM
Last Post: MichaIng
  RETRO-GAMING: UPDATED RELEASE OF RECALBOX FOR THE ROCK64 Mrfixit2001 31 17,376 12-21-2020, 08:17 AM
Last Post: hermes73
  RetroPie on Rock64 Luke 40 22,056 10-31-2020, 07:12 AM
Last Post: BigSkyEntertainment
  Lakka (retrogaming) os for rock64 Wizardknight 2 863 09-21-2020, 07:18 PM
Last Post: Wizardknight
  Debian (Vanilla) on Rock64 and eMMC - how ? as365n4 4 1,422 09-21-2020, 04:33 AM
Last Post: as365n4
Sad Rock64 crash randomly during usb 3 copy with RAID1 drive phalae 24 14,663 09-14-2020, 10:48 AM
Last Post: BrownLuther007

Forum Jump:


Users browsing this thread: 2 Guest(s)