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
6 * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net>
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
[] = {
28 .gpio
= WGT634U_GPIO_LED
,
30 .default_trigger
= "heartbeat",
34 static struct gpio_led_platform_data wgt634u_led_data
= {
35 .num_leds
= ARRAY_SIZE(wgt634u_leds
),
39 static struct platform_device wgt634u_gpio_leds
= {
43 .platform_data
= &wgt634u_led_data
,
48 /* 8MiB flash. The struct mtd_partition matches original Netgear WGT634U
50 static struct mtd_partition wgt634u_partitions
[] = {
54 .size
= 0x60000, /* 384k */
55 .mask_flags
= MTD_WRITEABLE
/* force read-only */
60 .size
= 0x20000 /* 128k */
65 .size
= 0x140000 /* 1280k */
70 .size
= 0x620000 /* 6272k */
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",
91 .dev
= { .platform_data
= &wgt634u_flash_data
, },
92 .resource
= &wgt634u_flash_resource
,
96 /* Platform devices */
97 static struct platform_device
*wgt634u_devices
[] __initdata
= {
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
120 return platform_add_devices(wgt634u_devices
,
121 ARRAY_SIZE(wgt634u_devices
));
126 module_init(wgt634u_init
);