Linux 2.6.25.3
[linux/fpc-iii.git] / arch / mips / bcm47xx / wgt634u.c
blobd1d90c9ef2fa7382fa6b65fe3e34778ad843e3c1
1 /*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
6 * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net>
7 */
9 #include <linux/platform_device.h>
10 #include <linux/module.h>
11 #include <linux/leds.h>
12 #include <linux/mtd/physmap.h>
13 #include <linux/ssb/ssb.h>
14 #include <asm/mach-bcm47xx/bcm47xx.h>
16 /* GPIO definitions for the WGT634U */
17 #define WGT634U_GPIO_LED 3
18 #define WGT634U_GPIO_RESET 2
19 #define WGT634U_GPIO_TP1 7
20 #define WGT634U_GPIO_TP2 6
21 #define WGT634U_GPIO_TP3 5
22 #define WGT634U_GPIO_TP4 4
23 #define WGT634U_GPIO_TP5 1
25 static struct gpio_led wgt634u_leds[] = {
27 .name = "power",
28 .gpio = WGT634U_GPIO_LED,
29 .active_low = 1,
30 .default_trigger = "heartbeat",
34 static struct gpio_led_platform_data wgt634u_led_data = {
35 .num_leds = ARRAY_SIZE(wgt634u_leds),
36 .leds = wgt634u_leds,
39 static struct platform_device wgt634u_gpio_leds = {
40 .name = "leds-gpio",
41 .id = -1,
42 .dev = {
43 .platform_data = &wgt634u_led_data,
48 /* 8MiB flash. The struct mtd_partition matches original Netgear WGT634U
49 firmware. */
50 static struct mtd_partition wgt634u_partitions[] = {
52 .name = "cfe",
53 .offset = 0,
54 .size = 0x60000, /* 384k */
55 .mask_flags = MTD_WRITEABLE /* force read-only */
58 .name = "config",
59 .offset = 0x60000,
60 .size = 0x20000 /* 128k */
63 .name = "linux",
64 .offset = 0x80000,
65 .size = 0x140000 /* 1280k */
68 .name = "jffs",
69 .offset = 0x1c0000,
70 .size = 0x620000 /* 6272k */
73 .name = "nvram",
74 .offset = 0x7e0000,
75 .size = 0x20000 /* 128k */
79 static struct physmap_flash_data wgt634u_flash_data = {
80 .parts = wgt634u_partitions,
81 .nr_parts = ARRAY_SIZE(wgt634u_partitions)
84 static struct resource wgt634u_flash_resource = {
85 .flags = IORESOURCE_MEM,
88 static struct platform_device wgt634u_flash = {
89 .name = "physmap-flash",
90 .id = 0,
91 .dev = { .platform_data = &wgt634u_flash_data, },
92 .resource = &wgt634u_flash_resource,
93 .num_resources = 1,
96 /* Platform devices */
97 static struct platform_device *wgt634u_devices[] __initdata = {
98 &wgt634u_flash,
99 &wgt634u_gpio_leds,
102 static int __init wgt634u_init(void)
104 /* There is no easy way to detect that we are running on a WGT634U
105 * machine. Use the MAC address as an heuristic. Netgear Inc. has
106 * been allocated ranges 00:09:5b:xx:xx:xx and 00:0f:b5:xx:xx:xx.
109 u8 *et0mac = ssb_bcm47xx.sprom.et0mac;
111 if (et0mac[0] == 0x00 &&
112 ((et0mac[1] == 0x09 && et0mac[2] == 0x5b) ||
113 (et0mac[1] == 0x0f && et0mac[2] == 0xb5))) {
114 struct ssb_mipscore *mcore = &ssb_bcm47xx.mipscore;
115 wgt634u_flash_data.width = mcore->flash_buswidth;
116 wgt634u_flash_resource.start = mcore->flash_window;
117 wgt634u_flash_resource.end = mcore->flash_window
118 + mcore->flash_window_size
119 - 1;
120 return platform_add_devices(wgt634u_devices,
121 ARRAY_SIZE(wgt634u_devices));
122 } else
123 return -ENODEV;
126 module_init(wgt634u_init);