2 * Sitecom RDC321x platform devices
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>
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.
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.
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.
25 #include <linux/init.h>
26 #include <linux/mtd/physmap.h>
27 #include <linux/input.h>
29 #include <asm/rdc_boards.h>
39 static struct gpio_led sitecom_leds
[] = {
40 { .name
= "rdc321x:power", .gpio
= 15, .active_low
= 1},
41 { .name
= "rdc321x:usb0", .gpio
= 0, .active_low
= 1},
42 { .name
= "rdc321x:usb1", .gpio
= 1, .active_low
= 1},
45 static struct gpio_button sitecom_btns
[] = {
54 static int __init
parse_sitecom_partitions(struct mtd_info
*master
, struct mtd_partition
**pparts
, unsigned long plat_data
)
56 struct image_header header
;
59 struct mtd_partition
*rdc_flash_parts
;
60 struct rdc_platform_data
*pdata
= (struct rdc_platform_data
*) plat_data
;
62 if (master
->size
!= 0x400000) //4MB
65 res
= master
->read(master
, 0x8000, sizeof(header
), &len
, (char *)&header
);
69 if (strncmp(header
.magic
, "CSYS", 4) || strncmp(header
.magic2
, "WRRM", 4))
72 rdc_flash_parts
= kzalloc(sizeof(struct mtd_partition
) * 5, GFP_KERNEL
);
74 rdc_flash_parts
[0].name
= "firmware";
75 rdc_flash_parts
[0].offset
= 0x8000;
76 rdc_flash_parts
[0].size
= 0x3F0000;
77 rdc_flash_parts
[1].name
= "config";
78 rdc_flash_parts
[1].offset
= 0;
79 rdc_flash_parts
[1].size
= 0x8000;
80 rdc_flash_parts
[2].name
= "kernel";
81 rdc_flash_parts
[2].offset
= 0x8014;
82 rdc_flash_parts
[2].size
= header
.kernel_length
;
83 rdc_flash_parts
[3].name
= "rootfs";
84 rdc_flash_parts
[3].offset
= 0x8014 + header
.kernel_length
;
85 rdc_flash_parts
[3].size
= 0x3F0000 - rdc_flash_parts
[3].offset
;
86 rdc_flash_parts
[4].name
= "bootloader";
87 rdc_flash_parts
[4].offset
= 0x3F0000;
88 rdc_flash_parts
[4].size
= 0x10000;
90 *pparts
= rdc_flash_parts
;
92 pdata
->led_data
.num_leds
= ARRAY_SIZE(sitecom_leds
);
93 pdata
->led_data
.leds
= sitecom_leds
;
94 pdata
->button_data
.nbuttons
= ARRAY_SIZE(sitecom_btns
);
95 pdata
->button_data
.buttons
= sitecom_btns
;
100 struct mtd_part_parser __initdata sitecom_parser
= {
101 .owner
= THIS_MODULE
,
102 .parse_fn
= parse_sitecom_partitions
,
106 static int __init
sitecom_setup(void)
108 return register_mtd_parser(&sitecom_parser
);
111 arch_initcall(sitecom_setup
);