blob: d1d90c9ef2fa7382fa6b65fe3e34778ad843e3c1 [file] [log] [blame]
Aurelien Jarno21c854d2007-09-25 15:43:07 +02001/*
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.
5 *
6 * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net>
7 */
8
9#include <linux/platform_device.h>
10#include <linux/module.h>
11#include <linux/leds.h>
Aurelien Jarno07881502008-02-07 03:17:16 +010012#include <linux/mtd/physmap.h>
Aurelien Jarno21c854d2007-09-25 15:43:07 +020013#include <linux/ssb/ssb.h>
14#include <asm/mach-bcm47xx/bcm47xx.h>
15
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
24
25static struct gpio_led wgt634u_leds[] = {
26 {
27 .name = "power",
28 .gpio = WGT634U_GPIO_LED,
29 .active_low = 1,
30 .default_trigger = "heartbeat",
31 },
32};
33
34static struct gpio_led_platform_data wgt634u_led_data = {
35 .num_leds = ARRAY_SIZE(wgt634u_leds),
36 .leds = wgt634u_leds,
37};
38
39static struct platform_device wgt634u_gpio_leds = {
40 .name = "leds-gpio",
41 .id = -1,
42 .dev = {
43 .platform_data = &wgt634u_led_data,
44 }
45};
46
Aurelien Jarno07881502008-02-07 03:17:16 +010047
48/* 8MiB flash. The struct mtd_partition matches original Netgear WGT634U
49 firmware. */
50static struct mtd_partition wgt634u_partitions[] = {
51 {
52 .name = "cfe",
53 .offset = 0,
54 .size = 0x60000, /* 384k */
55 .mask_flags = MTD_WRITEABLE /* force read-only */
56 },
57 {
58 .name = "config",
59 .offset = 0x60000,
60 .size = 0x20000 /* 128k */
61 },
62 {
63 .name = "linux",
64 .offset = 0x80000,
65 .size = 0x140000 /* 1280k */
66 },
67 {
68 .name = "jffs",
69 .offset = 0x1c0000,
70 .size = 0x620000 /* 6272k */
71 },
72 {
73 .name = "nvram",
74 .offset = 0x7e0000,
75 .size = 0x20000 /* 128k */
76 },
77};
78
79static struct physmap_flash_data wgt634u_flash_data = {
80 .parts = wgt634u_partitions,
81 .nr_parts = ARRAY_SIZE(wgt634u_partitions)
82};
83
84static struct resource wgt634u_flash_resource = {
85 .flags = IORESOURCE_MEM,
86};
87
88static 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,
94};
95
96/* Platform devices */
97static struct platform_device *wgt634u_devices[] __initdata = {
98 &wgt634u_flash,
99 &wgt634u_gpio_leds,
100};
101
Aurelien Jarno21c854d2007-09-25 15:43:07 +0200102static int __init wgt634u_init(void)
103{
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.
107 */
108
Aurelien Jarnocc2d6f72008-02-18 11:04:31 +0100109 u8 *et0mac = ssb_bcm47xx.sprom.et0mac;
Aurelien Jarno21c854d2007-09-25 15:43:07 +0200110
111 if (et0mac[0] == 0x00 &&
112 ((et0mac[1] == 0x09 && et0mac[2] == 0x5b) ||
Aurelien Jarno07881502008-02-07 03:17:16 +0100113 (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
Aurelien Jarno21c854d2007-09-25 15:43:07 +0200123 return -ENODEV;
124}
125
126module_init(wgt634u_init);
127