X-Git-Url: http://git.rohieb.name/openwrt.git/blobdiff_plain/ec6d32f924ee9e6b4d58885d2f692c8c2a4a2773..462336ec0941597e0c86161d0d073a82e6228a17:/target/linux/adm5120/files/drivers/mtd/maps/adm5120-flash.c 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..ed407ebde 100644 --- a/target/linux/adm5120/files/drivers/mtd/maps/adm5120-flash.c +++ b/target/linux/adm5120/files/drivers/mtd/maps/adm5120-flash.c @@ -1,29 +1,15 @@ /* - * $Id$ - * * Platform driver for NOR flash devices on ADM5120 based boards * - * Copyright (C) 2007 OpenWrt.org - * Copyright (C) 2007 Gabor Juhos + * Copyright (C) 2007-2008 Gabor Juhos * * This file was derived from: drivers/mtd/map/physmap.c * Copyright (C) 2003 MontaVista Software Inc. * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. * */ @@ -40,10 +26,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #define DRV_NAME "adm5120-flash" #define DRV_DESC "ADM5120 flash MAP driver" @@ -220,14 +206,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,9 +231,9 @@ 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; + map->name = dev_name(&dev->dev); if (dev->id > 1) { MAP_ERR(map, "invalid flash id\n"); @@ -255,12 +242,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(SWITCH_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; } @@ -570,6 +563,6 @@ static void __exit adm5120_flash_exit(void) module_init(adm5120_flash_init); module_exit(adm5120_flash_exit); -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Gabor Juhos "); +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Gabor Juhos "); MODULE_DESCRIPTION(DRV_DESC);