X-Git-Url: http://git.rohieb.name/openwrt.git/blobdiff_plain/ec6d32f924ee9e6b4d58885d2f692c8c2a4a2773..26e53509080efd718c6ab55eb00384d3d470a7e5:/target/linux/adm5120/files/drivers/mtd/maps/adm5120-flash.c?ds=sidebyside diff --git a/target/linux/adm5120/files/drivers/mtd/maps/adm5120-flash.c b/target/linux/adm5120/files/drivers/mtd/maps/adm5120-flash.c index e07fb96d2..824d2f5e8 100644 --- a/target/linux/adm5120/files/drivers/mtd/maps/adm5120-flash.c +++ b/target/linux/adm5120/files/drivers/mtd/maps/adm5120-flash.c @@ -220,14 +220,15 @@ static int adm5120_flash_initres(struct adm5120_flash_info *info) struct map_info *map = &info->amap.map; int err = 0; - info->res = request_mem_region(map->phys, map->size, map->name); + info->res = request_mem_region(map->phys, info->amap.window_size, + map->name); if (info->res == NULL) { MAP_ERR(map, "could not reserve memory region\n"); err = -ENOMEM; goto out; } - map->virt = ioremap_nocache(map->phys, map->size); + map->virt = ioremap_nocache(map->phys, info->amap.window_size); if (map->virt == NULL) { MAP_ERR(map, "failed to ioremap flash region\n"); err = -ENOMEM; @@ -244,7 +245,7 @@ static int adm5120_flash_initinfo(struct adm5120_flash_info *info, struct map_info *map = &info->amap.map; struct adm5120_flash_platform_data *pdata = dev->dev.platform_data; struct flash_desc *fdesc; - u32 t; + u32 t = 0; map->name = dev->dev.bus_id; @@ -255,12 +256,18 @@ static int adm5120_flash_initinfo(struct adm5120_flash_info *info, fdesc = &flash_descs[dev->id]; - /* get memory window size */ - t = SW_READ_REG(MEMCTRL) >> fdesc->srs_shift; - t &= MEMCTRL_SRS_MASK; - info->amap.window_size = flash_sizes[t]; + if (pdata) + info->amap.window_size = pdata->window_size; + + if (info->amap.window_size == 0) { + /* get memory window size */ + t = SW_READ_REG(MEMCTRL) >> fdesc->srs_shift; + t &= MEMCTRL_SRS_MASK; + info->amap.window_size = flash_sizes[t]; + } + if (info->amap.window_size == 0) { - MAP_ERR(map, "invalid flash size detected\n"); + MAP_ERR(map, "unable to determine window size\n"); goto err_out; }