[ramips] share machine registration code
[openwrt.git] / target / linux / ramips / files / arch / mips / ralink / rt305x / mach-whr-g300n.c
1 /*
2  *  Buffalo WHR-G300N board support
3  *
4  *  Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
5  *
6  *  This program is free software; you can redistribute it and/or modify it
7  *  under the terms of the GNU General Public License version 2 as published
8  *  by the Free Software Foundation.
9  */
10
11 #include <linux/init.h>
12 #include <linux/platform_device.h>
13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/partitions.h>
15 #include <linux/mtd/physmap.h>
16 #include <linux/leds.h>
17
18 #include <asm/mips_machine.h>
19 #include <asm/mach-ralink/machine.h>
20 #include <asm/mach-ralink/dev_gpio_leds.h>
21
22 #include "devices.h"
23
24 #define WHR_G300N_GPIO_LED_DIAG         7
25 #define WHR_G300N_GPIO_LED_ROUTER       9
26 #define WHR_G300N_GPIO_LED_SECURITY     14
27
28 #ifdef CONFIG_MTD_PARTITIONS
29 static struct mtd_partition whr_g300n_partitions[] = {
30         {
31                 .name   = "u-boot",
32                 .offset = 0,
33                 .size   = 0x030000,
34                 .mask_flags = MTD_WRITEABLE,
35         }, {
36                 .name   = "u-boot-env",
37                 .offset = 0x030000,
38                 .size   = 0x010000,
39                 .mask_flags = MTD_WRITEABLE,
40         }, {
41                 .name   = "factory",
42                 .offset = 0x040000,
43                 .size   = 0x010000,
44                 .mask_flags = MTD_WRITEABLE,
45         }, {
46                 .name   = "kernel",
47                 .offset = 0x050000,
48                 .size   = 0x090000,
49         }, {
50                 .name   = "rootfs",
51                 .offset = 0x140000,
52                 .size   = 0x2B0000,
53         }, {
54                 .name   = "user",
55                 .offset = 0x3f0000,
56                 .size   = 0x010000,
57         }, {
58                 .name   = "openwrt",
59                 .offset = 0x050000,
60                 .size   = 0x3a0000,
61         }
62 };
63 #endif /* CONFIG_MTD_PARTITIONS */
64
65 static struct physmap_flash_data whr_g300n_flash_data = {
66 #ifdef CONFIG_MTD_PARTITIONS
67         .nr_parts       = ARRAY_SIZE(whr_g300n_partitions),
68         .parts          = whr_g300n_partitions,
69 #endif
70 };
71
72 static struct gpio_led whr_g300n_leds_gpio[] __initdata = {
73         {
74                 .name           = "whr-g300n:red:diag",
75                 .gpio           = WHR_G300N_GPIO_LED_DIAG,
76                 .active_low     = 1,
77         }, {
78                 .name           = "whr-g300n:green:router",
79                 .gpio           = WHR_G300N_GPIO_LED_ROUTER,
80                 .active_low     = 1,
81         }, {
82                 .name           = "whr-g300n:amber:security",
83                 .gpio           = WHR_G300N_GPIO_LED_SECURITY,
84                 .active_low     = 1,
85         }
86 };
87
88 static void __init whr_g300n_init(void)
89 {
90         rt305x_register_flash(0, &whr_g300n_flash_data);
91
92         ramips_register_gpio_leds(-1, ARRAY_SIZE(whr_g300n_leds_gpio),
93                                   whr_g300n_leds_gpio);
94 }
95
96 MIPS_MACHINE(RAMIPS_MACH_WHR_G300N, "Buffalo WHR-G300N", whr_g300n_init);