/*
- * $Id$
- *
* Platform driver for NOR flash devices on ADM5120 based boards
*
- * Copyright (C) 2007 OpenWrt.org
- * Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
+ * Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
*
* 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.
*
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/slab.h>
+#include <linux/io.h>
#include <linux/device.h>
-
#include <linux/platform_device.h>
+
#include <linux/mtd/mtd.h>
#include <linux/mtd/map.h>
#include <linux/mtd/partitions.h>
-#include <asm/io.h>
-
-#include <adm5120_defs.h>
-#include <adm5120_switch.h>
-#include <adm5120_mpmc.h>
-#include <adm5120_platform.h>
+#include <asm/mach-adm5120/adm5120_defs.h>
+#include <asm/mach-adm5120/adm5120_switch.h>
+#include <asm/mach-adm5120/adm5120_mpmc.h>
+#include <asm/mach-adm5120/adm5120_platform.h>
#define DRV_NAME "adm5120-flash"
#define DRV_DESC "ADM5120 flash MAP driver"
{
struct adm5120_map_info *amap = map_to_amap(map);
- MAP_DBG(map,"writing to ofs %lX\n", ofs);
+ MAP_DBG(map, "writing to ofs %lX\n", ofs);
if (ofs > amap->window_size)
return;
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;
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;
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;
}
#ifdef CONFIG_MTD_PARTITIONS
static int adm5120_flash_initparts(struct adm5120_flash_info *info)
{
- struct adm5120_flash_platform_data *pdata = info->dev->dev.platform_data;
+ struct adm5120_flash_platform_data *pdata;
struct map_info *map = &info->amap.map;
int num_parsers;
const char *parser[2];
info->nr_parts = 0;
+ pdata = info->dev->dev.platform_data;
if (pdata == NULL)
goto out;
num_parsers = MAX_PARSED_PARTS;
parser[1] = NULL;
- for (i=0; i<num_parsers; i++) {
+ for (i = 0; i < num_parsers; i++) {
parser[0] = parse_types[i];
MAP_INFO(map, "parsing \"%s\" partitions\n",
if (info->nr_parts) {
del_mtd_partitions(info->mtd);
- for (i=0; i<MAX_PARSED_PARTS; i++)
+ for (i = 0; i < MAX_PARSED_PARTS; i++)
if (info->parts[i] != NULL)
kfree(info->parts[i]);
} else {
goto err_out;
if (info->nr_parts == 0) {
- MAP_INFO(map, "no partitions available, registering whole flash\n");
+ MAP_INFO(map, "no partitions available, registering "
+ "whole flash\n");
add_mtd_device(info->mtd);
}
}
#ifdef CONFIG_PM
-static int adm5120_flash_suspend(struct platform_device *dev, pm_message_t state)
+static int adm5120_flash_suspend(struct platform_device *dev,
+ pm_message_t state)
{
struct adm5120_flash_info *info = platform_get_drvdata(dev);
int ret = 0;
module_init(adm5120_flash_init);
module_exit(adm5120_flash_exit);
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Gabor Juhos <juhosg at openwrt.org>");
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
MODULE_DESCRIPTION(DRV_DESC);