diff options
author | Aurelien Jarno <aurelien@aurel32.net> | 2008-02-06 21:17:16 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2008-02-19 12:01:34 -0500 |
commit | 0788150e639623f44c5991dcd290f8cdcf7db43f (patch) | |
tree | 1052e8b6d3eec612f7ca8f785800907df24e3b4c | |
parent | e8248d6fe7092439b08588102ad668b7cf27ec05 (diff) |
[MIPS] WGT634U: Register MTD as platform device.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r-- | arch/mips/bcm47xx/wgt634u.c | 69 |
1 files changed, 66 insertions, 3 deletions
diff --git a/arch/mips/bcm47xx/wgt634u.c b/arch/mips/bcm47xx/wgt634u.c index 5a017eaee712..997e54001717 100644 --- a/arch/mips/bcm47xx/wgt634u.c +++ b/arch/mips/bcm47xx/wgt634u.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/platform_device.h> | 9 | #include <linux/platform_device.h> |
10 | #include <linux/module.h> | 10 | #include <linux/module.h> |
11 | #include <linux/leds.h> | 11 | #include <linux/leds.h> |
12 | #include <linux/mtd/physmap.h> | ||
12 | #include <linux/ssb/ssb.h> | 13 | #include <linux/ssb/ssb.h> |
13 | #include <asm/mach-bcm47xx/bcm47xx.h> | 14 | #include <asm/mach-bcm47xx/bcm47xx.h> |
14 | 15 | ||
@@ -43,6 +44,61 @@ static struct platform_device wgt634u_gpio_leds = { | |||
43 | } | 44 | } |
44 | }; | 45 | }; |
45 | 46 | ||
47 | |||
48 | /* 8MiB flash. The struct mtd_partition matches original Netgear WGT634U | ||
49 | firmware. */ | ||
50 | static 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 | |||
79 | static struct physmap_flash_data wgt634u_flash_data = { | ||
80 | .parts = wgt634u_partitions, | ||
81 | .nr_parts = ARRAY_SIZE(wgt634u_partitions) | ||
82 | }; | ||
83 | |||
84 | static struct resource wgt634u_flash_resource = { | ||
85 | .flags = IORESOURCE_MEM, | ||
86 | }; | ||
87 | |||
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, | ||
94 | }; | ||
95 | |||
96 | /* Platform devices */ | ||
97 | static struct platform_device *wgt634u_devices[] __initdata = { | ||
98 | &wgt634u_flash, | ||
99 | &wgt634u_gpio_leds, | ||
100 | }; | ||
101 | |||
46 | static int __init wgt634u_init(void) | 102 | static int __init wgt634u_init(void) |
47 | { | 103 | { |
48 | /* There is no easy way to detect that we are running on a WGT634U | 104 | /* There is no easy way to detect that we are running on a WGT634U |
@@ -54,9 +110,16 @@ static int __init wgt634u_init(void) | |||
54 | 110 | ||
55 | if (et0mac[0] == 0x00 && | 111 | if (et0mac[0] == 0x00 && |
56 | ((et0mac[1] == 0x09 && et0mac[2] == 0x5b) || | 112 | ((et0mac[1] == 0x09 && et0mac[2] == 0x5b) || |
57 | (et0mac[1] == 0x0f && et0mac[2] == 0xb5))) | 113 | (et0mac[1] == 0x0f && et0mac[2] == 0xb5))) { |
58 | return platform_device_register(&wgt634u_gpio_leds); | 114 | struct ssb_mipscore *mcore = &ssb_bcm47xx.mipscore; |
59 | else | 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 | ||
60 | return -ENODEV; | 123 | return -ENODEV; |
61 | } | 124 | } |
62 | 125 | ||