diff options
author | root <root@avtech.domain.avtechpulse.com> | 2000-01-01 00:34:23 +0900 |
---|---|---|
committer | root <root@avtech.domain.avtechpulse.com> | 2000-01-01 00:34:23 +0900 |
commit | 4553ffb49fada86a35ec0160b42b3f91ecba9ad3 (patch) | |
tree | 27ad444fb254c91d3ecc5575feaffad3dd68126c /bus.c | |
parent | 2b052086ac0e27a19a69f136e320758da8fb0bea (diff) |
add code to detect beaglebone vs olimex
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(); |