memory: omap-gpmc: Prevent mapping into 1st 16MB
[cascardo/linux.git] / drivers / memory / omap-gpmc.c
index 8dc6e3b..bfe4e87 100644 (file)
 #define GPMC_CS_SIZE           0x30
 #define        GPMC_BCH_SIZE           0x10
 
+/*
+ * The first 1MB of GPMC address space is typically mapped to
+ * the internal ROM. Never allocate the first page, to
+ * facilitate bug detection; even if we didn't boot from ROM.
+ * As GPMC minimum partition size is 16MB we can only start from
+ * there.
+ */
+#define GPMC_MEM_START         0x1000000
 #define GPMC_MEM_END           0x3FFFFFFF
 
 #define GPMC_CHUNK_SHIFT       24              /* 16 MB */
@@ -1297,12 +1305,7 @@ static void gpmc_mem_init(void)
 {
        int cs;
 
-       /*
-        * The first 1MB of GPMC address space is typically mapped to
-        * the internal ROM. Never allocate the first page, to
-        * facilitate bug detection; even if we didn't boot from ROM.
-        */
-       gpmc_mem_root.start = SZ_1M;
+       gpmc_mem_root.start = GPMC_MEM_START;
        gpmc_mem_root.end = GPMC_MEM_END;
 
        /* Reserve all regions that has been set up by bootloader */
@@ -1966,6 +1969,15 @@ static int gpmc_probe_generic_child(struct platform_device *pdev,
        if (ret < 0) {
                dev_err(&pdev->dev, "cannot remap GPMC CS %d to %pa\n",
                        cs, &res.start);
+               if (res.start < GPMC_MEM_START) {
+                       dev_info(&pdev->dev,
+                                "GPMC CS %d start cannot be lesser than 0x%x\n",
+                                cs, GPMC_MEM_START);
+               } else if (res.end > GPMC_MEM_END) {
+                       dev_info(&pdev->dev,
+                                "GPMC CS %d end cannot be greater than 0x%x\n",
+                                cs, GPMC_MEM_END);
+               }
                goto err;
        }