| 1 | /* |
| 2 | * Generic RDC321x platform devices |
| 3 | * |
| 4 | * Copyright (C) 2007-2009 OpenWrt.org |
| 5 | * Copyright (C) 2007 Florian Fainelli <florian@openwrt.org> |
| 6 | * Copyright (C) 2008-2009 Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License |
| 10 | * as published by the Free Software Foundation; either version 2 |
| 11 | * of the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the |
| 20 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 21 | * Boston, MA 02110-1301, USA. |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #include <linux/init.h> |
| 26 | //#include <linux/kernel.h> |
| 27 | //#include <linux/list.h> |
| 28 | //#include <linux/device.h> |
| 29 | #include <linux/platform_device.h> |
| 30 | //#include <linux/version.h> |
| 31 | //#include <linux/input.h> |
| 32 | #include <linux/mtd/map.h> |
| 33 | #include <linux/mtd/mtd.h> |
| 34 | #include <linux/mtd/physmap.h> |
| 35 | #include <linux/root_dev.h> |
| 36 | |
| 37 | #include <asm/rdc_boards.h> |
| 38 | |
| 39 | static struct rdc_platform_data rdcplat_data; |
| 40 | |
| 41 | /* LEDS */ |
| 42 | static struct platform_device rdc321x_leds = { |
| 43 | .name = "leds-gpio", |
| 44 | .id = -1, |
| 45 | .dev = { |
| 46 | .platform_data = &rdcplat_data.led_data, |
| 47 | } |
| 48 | }; |
| 49 | |
| 50 | /* Button */ |
| 51 | static struct platform_device rdc321x_buttons = { |
| 52 | .name = "gpio-buttons", |
| 53 | .id = -1, |
| 54 | .dev = { |
| 55 | .platform_data = &rdcplat_data.button_data, |
| 56 | } |
| 57 | }; |
| 58 | |
| 59 | static __initdata struct platform_device *rdc321x_devs[] = { |
| 60 | &rdc321x_leds, |
| 61 | &rdc321x_buttons, |
| 62 | }; |
| 63 | |
| 64 | const char *__initdata boards[] = { |
| 65 | "Sitecom", |
| 66 | "AR525W", |
| 67 | "Bifferboard", |
| 68 | "R8610", |
| 69 | 0 |
| 70 | }; |
| 71 | |
| 72 | static struct map_info rdc_map_info = { |
| 73 | .name = "rdc_flash", |
| 74 | .size = 0x800000, //8MB |
| 75 | .phys = 0xFF800000, //(u32) -rdc_map_info.size; |
| 76 | .bankwidth = 2 |
| 77 | }; |
| 78 | |
| 79 | static int __init rdc_board_setup(void) |
| 80 | { |
| 81 | struct mtd_partition *partitions; |
| 82 | int count, res; |
| 83 | struct mtd_info *mtdinfo; |
| 84 | |
| 85 | simple_map_init(&rdc_map_info); |
| 86 | |
| 87 | while (true) { |
| 88 | rdc_map_info.virt = ioremap(rdc_map_info.phys, rdc_map_info.size); |
| 89 | if (rdc_map_info.virt == NULL) |
| 90 | continue; |
| 91 | |
| 92 | mtdinfo = do_map_probe("cfi_probe", &rdc_map_info); |
| 93 | if (mtdinfo == NULL) |
| 94 | mtdinfo = do_map_probe("jedec_probe", &rdc_map_info); |
| 95 | if (mtdinfo != NULL) |
| 96 | break; |
| 97 | |
| 98 | iounmap(rdc_map_info.virt); |
| 99 | if ((rdc_map_info.size >>= 1) < 0x100000) //1MB |
| 100 | panic("RDC321x: Could not find start of flash!"); |
| 101 | rdc_map_info.phys = (u32) -rdc_map_info.size; |
| 102 | } |
| 103 | |
| 104 | count = parse_mtd_partitions(mtdinfo, boards, &partitions, (unsigned long) &rdcplat_data); |
| 105 | |
| 106 | if (count <= 0) { |
| 107 | panic("RDC321x: can't identify board type"); |
| 108 | return -ENOSYS; |
| 109 | } |
| 110 | |
| 111 | ROOT_DEV = 0; |
| 112 | res = add_mtd_partitions(mtdinfo, partitions, count); |
| 113 | if (res) |
| 114 | return res; |
| 115 | |
| 116 | return platform_add_devices(rdc321x_devs, ARRAY_SIZE(rdc321x_devs)); |
| 117 | |
| 118 | } |
| 119 | |
| 120 | late_initcall(rdc_board_setup); |
| 121 | |