2009-11-03 01:07:47 +02:00
|
|
|
/*
|
|
|
|
* Generic RDC321x platform devices
|
|
|
|
*
|
2009-11-06 12:53:15 +02:00
|
|
|
* Copyright (C) 2007-2009 OpenWrt.org
|
2009-11-03 01:07:47 +02:00
|
|
|
* Copyright (C) 2007 Florian Fainelli <florian@openwrt.org>
|
2009-11-06 12:53:15 +02:00
|
|
|
* Copyright (C) 2008-2009 Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
|
2009-11-03 01:07:47 +02:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
2010-03-19 01:35:21 +02:00
|
|
|
//#include <linux/kernel.h>
|
|
|
|
//#include <linux/list.h>
|
|
|
|
//#include <linux/device.h>
|
2009-11-03 01:07:47 +02:00
|
|
|
#include <linux/platform_device.h>
|
2010-03-19 01:35:21 +02:00
|
|
|
//#include <linux/version.h>
|
|
|
|
//#include <linux/input.h>
|
2009-11-03 01:07:47 +02:00
|
|
|
#include <linux/mtd/map.h>
|
|
|
|
#include <linux/mtd/mtd.h>
|
|
|
|
#include <linux/mtd/physmap.h>
|
|
|
|
#include <linux/root_dev.h>
|
|
|
|
|
2010-03-19 01:35:21 +02:00
|
|
|
#include <asm/rdc_boards.h>
|
2009-11-03 01:07:47 +02:00
|
|
|
|
2010-03-19 01:35:21 +02:00
|
|
|
static struct rdc_platform_data rdcplat_data;
|
2009-11-03 01:07:47 +02:00
|
|
|
|
|
|
|
/* LEDS */
|
|
|
|
static struct platform_device rdc321x_leds = {
|
|
|
|
.name = "leds-gpio",
|
|
|
|
.id = -1,
|
|
|
|
.dev = {
|
2010-03-19 01:35:21 +02:00
|
|
|
.platform_data = &rdcplat_data.led_data,
|
2009-11-03 01:07:47 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Button */
|
2010-03-19 01:35:21 +02:00
|
|
|
static struct platform_device rdc321x_buttons = {
|
2010-03-04 10:27:59 +02:00
|
|
|
.name = "gpio-buttons",
|
2009-11-03 01:07:47 +02:00
|
|
|
.id = -1,
|
|
|
|
.dev = {
|
2010-03-19 01:35:21 +02:00
|
|
|
.platform_data = &rdcplat_data.button_data,
|
2009-11-03 01:07:47 +02:00
|
|
|
}
|
|
|
|
};
|
2010-03-19 01:35:21 +02:00
|
|
|
|
|
|
|
static __initdata struct platform_device *rdc321x_devs[] = {
|
2009-11-03 01:07:47 +02:00
|
|
|
&rdc321x_leds,
|
2010-03-19 01:35:21 +02:00
|
|
|
&rdc321x_buttons,
|
2009-11-03 01:07:47 +02:00
|
|
|
};
|
|
|
|
|
2010-03-19 01:35:21 +02:00
|
|
|
const char *__initdata boards[] = {
|
|
|
|
"Sitecom",
|
|
|
|
"AR525W",
|
|
|
|
"Bifferboard",
|
|
|
|
"R8610",
|
|
|
|
0
|
|
|
|
};
|
2009-11-03 01:07:47 +02:00
|
|
|
|
2010-03-19 01:35:21 +02:00
|
|
|
static struct map_info rdc_map_info = {
|
|
|
|
.name = "rdc_flash",
|
|
|
|
.size = 0x800000, //8MB
|
|
|
|
.phys = 0xFF800000, //(u32) -rdc_map_info.size;
|
|
|
|
.bankwidth = 2
|
|
|
|
};
|
2009-11-03 01:07:47 +02:00
|
|
|
|
|
|
|
static int __init rdc_board_setup(void)
|
|
|
|
{
|
2010-03-19 01:35:21 +02:00
|
|
|
struct mtd_partition *partitions;
|
|
|
|
int count, res;
|
|
|
|
struct mtd_info *mtdinfo;
|
|
|
|
|
2009-11-03 01:07:47 +02:00
|
|
|
simple_map_init(&rdc_map_info);
|
2010-03-19 01:35:21 +02:00
|
|
|
|
|
|
|
while (true) {
|
|
|
|
rdc_map_info.virt = ioremap(rdc_map_info.phys, rdc_map_info.size);
|
|
|
|
if (rdc_map_info.virt == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
mtdinfo = do_map_probe("cfi_probe", &rdc_map_info);
|
|
|
|
if (mtdinfo == NULL)
|
|
|
|
mtdinfo = do_map_probe("jedec_probe", &rdc_map_info);
|
|
|
|
if (mtdinfo != NULL)
|
|
|
|
break;
|
|
|
|
|
|
|
|
iounmap(rdc_map_info.virt);
|
|
|
|
if ((rdc_map_info.size >>= 1) < 0x100000) //1MB
|
|
|
|
panic("RDC321x: Could not find start of flash!");
|
2009-12-06 11:08:03 +02:00
|
|
|
rdc_map_info.phys = (u32) -rdc_map_info.size;
|
2009-11-03 01:07:47 +02:00
|
|
|
}
|
2010-03-19 01:35:21 +02:00
|
|
|
|
|
|
|
count = parse_mtd_partitions(mtdinfo, boards, &partitions, (unsigned long) &rdcplat_data);
|
|
|
|
|
|
|
|
if (count <= 0) {
|
|
|
|
panic("RDC321x: can't identify board type");
|
|
|
|
return -ENOSYS;
|
2009-11-03 01:07:47 +02:00
|
|
|
}
|
2010-03-19 01:35:21 +02:00
|
|
|
|
|
|
|
ROOT_DEV = 0;
|
|
|
|
res = add_mtd_partitions(mtdinfo, partitions, count);
|
|
|
|
if (res)
|
|
|
|
return res;
|
|
|
|
|
2009-11-03 01:07:47 +02:00
|
|
|
return platform_add_devices(rdc321x_devs, ARRAY_SIZE(rdc321x_devs));
|
2010-03-19 01:35:21 +02:00
|
|
|
|
2009-11-03 01:07:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
late_initcall(rdc_board_setup);
|