Commit 076f98c3 authored by Jochen Rößner's avatar Jochen Rößner

Erkennung neuer CPU, setzen des neuen gpio Adressbereichs

parent 6d43c5b9
......@@ -39,6 +39,9 @@ char *get_cpuinfo_revision(char *revision)
sscanf(buffer, "Hardware : %s", hardware);
if (strcmp(hardware, "BCM2708") == 0)
rpi_found = 1;
else if (strcmp(hardware, "BCM2709") == 0)
rpi_found = 1;
sscanf(buffer, "Revision : %s", revision);
}
fclose(fp);
......@@ -60,6 +63,37 @@ int get_rpi_revision(void)
(strcmp(revision, "0003") == 0) ||
(strcmp(revision, "1000003") == 0 ))
return 1;
else // assume rev 2 (0004 0005 0006 1000004 1000005 1000006)
else if ((strcmp(revision, "0004") == 0) ||
(strcmp(revision, "1000004") == 0 ) ||
(strcmp(revision, "0005") == 0) ||
(strcmp(revision, "1000005") == 0 ) ||
(strcmp(revision, "0006") == 0) ||
(strcmp(revision, "1000006") == 0 ))
return 2;
else if ((strcmp(revision, "a01041") == 0) ||
(strcmp(revision, "a21041") == 0 ))
return 3;
else // assume rev 4
return 4;
}
int number_of_cores(void)
{
char str[256];
int procCount = 0;
FILE *fp;
if( (fp = fopen("/proc/cpuinfo", "r")) )
{
while(fgets(str, sizeof str, fp))
if( !memcmp(str, "processor", 9) ) procCount++;
}
if ( !procCount )
{
printf("Unable to get proc count. Defaulting to 2");
procCount=2;
}
return procCount;
}
......@@ -30,7 +30,9 @@ SOFTWARE.
#include "gpio.h"
#define BCM2708_PERI_BASE 0x20000000
#define GPIO_BASE (BCM2708_PERI_BASE + 0x200000)
#define BCM2708_GPIO_BASE (BCM2708_PERI_BASE + 0x200000)
#define BCM2709_PERI_BASE 0x3f000000
#define BCM2709_GPIO_BASE (BCM2709_PERI_BASE + 0x200000)
#define FSEL_OFFSET 0 // 0x0000
#define SET_OFFSET 7 // 0x001c / 4
#define CLR_OFFSET 10 // 0x0028 / 4
......@@ -83,7 +85,11 @@ int setup(void)
if ((uint32_t)gpio_mem % PAGE_SIZE)
gpio_mem += PAGE_SIZE - ((uint32_t)gpio_mem % PAGE_SIZE);
gpio_map = (uint32_t *)mmap( (caddr_t)gpio_mem, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, mem_fd, GPIO_BASE);
if (get_rpi_revision() <= 2 || number_of_cores() <= 2)
gpio_map = (uint32_t *)mmap( (caddr_t)gpio_mem, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, mem_fd, BCM2708_GPIO_BASE);
else
gpio_map = (uint32_t *)mmap( (caddr_t)gpio_mem, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, mem_fd, BCM2709_GPIO_BASE);
if ((uint32_t)gpio_map < 0)
return SETUP_MMAP_FAIL;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment