summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bus.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/bus.c b/bus.c
index c45fda6..da5243a 100644
--- a/bus.c
+++ b/bus.c
@@ -183,19 +183,21 @@ static void gpmc_setup(int chipselect, int accesscycles, int size, bool enablecs
gpmc_mapregisters();
- // disable before playing with the registers..
- *(registers + displacement + GPMC_CONFIG7) = 0x0;
-
- *(registers + displacement + GPMC_CONFIG1) = 0x0;
- *(registers + displacement + GPMC_CONFIG2) = (accesscycles << CSWROFFTIME) | (accesscycles << CSRDOFFTIME);
- *(registers + displacement + GPMC_CONFIG3) = 0x0; // not using ADV so we can ignore this guy
- *(registers + displacement + GPMC_CONFIG4) = (accesscycles << OEOFFTIME);
- *(registers + displacement + GPMC_CONFIG5) = (accesscycles << RDACCESSTIME) | (accesscycles << WRCYCLETIME)
- | (accesscycles << RDCYCLETIME);
- *(registers + displacement + GPMC_CONFIG6) = (accesscycles << WRACCESSTIME);
- *(registers + displacement + GPMC_CONFIG7) = size << 8 | (enablecs ? 1 << 6 : 0) | baseaddress;
-
- gpmc_unmapregisters();
+ if (registers != MAP_FAILED) {
+ // disable before playing with the registers..
+ *(registers + displacement + GPMC_CONFIG7) = 0x0;
+
+ *(registers + displacement + GPMC_CONFIG1) = 0x0;
+ *(registers + displacement + GPMC_CONFIG2) = (accesscycles << CSWROFFTIME) | (accesscycles << CSRDOFFTIME);
+ *(registers + displacement + GPMC_CONFIG3) = 0x0; // not using ADV so we can ignore this guy
+ *(registers + displacement + GPMC_CONFIG4) = (accesscycles << OEOFFTIME);
+ *(registers + displacement + GPMC_CONFIG5) = (accesscycles << RDACCESSTIME) | (accesscycles << WRCYCLETIME)
+ | (accesscycles << RDCYCLETIME);
+ *(registers + displacement + GPMC_CONFIG6) = (accesscycles << WRACCESSTIME);
+ *(registers + displacement + GPMC_CONFIG7) = size << 8 | (enablecs ? 1 << 6 : 0) | baseaddress;
+
+ gpmc_unmapregisters();
+ }
}
/*