diff options
Diffstat (limited to 'bus.c')
-rw-r--r-- | bus.c | 42 |
1 files changed, 35 insertions, 7 deletions
@@ -59,13 +59,38 @@ static int devmemfd = -1; -static bool util_isbeaglebone() + +static bool util_model_is (char *check_model) +{ + FILE *fp; + char content[100]; + + if ((fp=fopen("/sys/firmware/devicetree/base/model", "r"))==NULL) { + return FALSE; + } + + while(fgets(content, sizeof(content), fp)) { + if(strstr(content,check_model)) { + return TRUE; + } + } + + return FALSE; +} + + +static bool util_is_beaglebone() +{ + return util_model_is ("TI AM335x BeagleBone"); +} + + +static bool util_is_olimex() { - int fd = open("/sys/devices/avtech.9/modalias", O_RDONLY); - close(fd); - return fd > -1; + return util_model_is ("Olimex AM335x SOM"); } + static void* util_mapmemoryblock(off_t offset, size_t len) { devmemfd = open("/dev/mem", O_RDWR | O_SYNC); @@ -323,11 +348,14 @@ static volatile uint8_t* extbus; void bus_init() { + globals.HWDetect.beaglebone = util_is_beaglebone(); + globals.HWDetect.olimex = util_is_olimex(); - globals.HWDetect.beaglebone = util_isbeaglebone(); + printf("Beaglebone: %d. Olimex: %d.\n", + globals.HWDetect.beaglebone, globals.HWDetect.olimex); - if (!globals.HWDetect.beaglebone) { - printf("This doesn't seem to be a beaglebone.. bus stuff disabled!\n"); + if (!globals.HWDetect.beaglebone && !globals.HWDetect.olimex) { + printf("No recognized hardware. Bus stuff disabled!\n"); } else { gpmc_setup(); |