93d28a5b2a62e0207c9f6d57d9f9c86301af1bce
[openwrt/openwrt.git] / target / linux / ramips / files / arch / mips / ralink / rt305x / mach-dir-300-revb.c
1 /*
2 * D-Link DIR-300 rev B 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/mach-ralink/machine.h>
19 #include <asm/mach-ralink/dev_gpio_leds.h>
20 #include <asm/mach-ralink/rt305x.h>
21 #include <asm/mach-ralink/rt305x_regs.h>
22
23 #include "devices.h"
24
25 #define DIR_300B_GPIO_LED_STATUS_AMBER 8
26 #define DIR_300B_GPIO_LED_STATUS_GREEN 9
27 #define DIR_300B_GPIO_LED_WPS 13
28
29 #define DIR_300B_GPIO_BUTTON_WPS 0 /* active low */
30 #define DIR_300B_GPIO_BUTTON_RESET 10 /* active low */
31
32 #ifdef CONFIG_MTD_PARTITIONS
33 static struct mtd_partition dir_300b_partitions[] = {
34 {
35 .name = "u-boot",
36 .offset = 0,
37 .size = 0x030000,
38 .mask_flags = MTD_WRITEABLE,
39 }, {
40 .name = "devdata",
41 .offset = 0x030000,
42 .size = 0x010000,
43 .mask_flags = MTD_WRITEABLE,
44 }, {
45 .name = "devconf",
46 .offset = 0x040000,
47 .size = 0x010000,
48 .mask_flags = MTD_WRITEABLE,
49 }, {
50 .name = "kernel",
51 .offset = 0x050000,
52 .size = 0x090000,
53 }, {
54 .name = "rootfs",
55 .offset = 0x140000,
56 .size = 0x2B0000,
57 }, {
58 .name = "openwrt",
59 .offset = 0x050000,
60 .size = 0x3a0000,
61 }
62 };
63 #endif /* CONFIG_MTD_PARTITIONS */
64
65 static struct physmap_flash_data dir_300b_flash_data = {
66 #ifdef CONFIG_MTD_PARTITIONS
67 .nr_parts = ARRAY_SIZE(dir_300b_partitions),
68 .parts = dir_300b_partitions,
69 #endif
70 };
71
72 static struct gpio_led dir_300b_leds_gpio[] __initdata = {
73 {
74 .name = "dir-300b:amber:status",
75 .gpio = DIR_300B_GPIO_LED_STATUS_AMBER,
76 .active_low = 1,
77 }, {
78 .name = "dir-300b:green:status",
79 .gpio = DIR_300B_GPIO_LED_STATUS_GREEN,
80 .active_low = 1,
81 }, {
82 .name = "dir-300b:blue:wps",
83 .gpio = DIR_300B_GPIO_LED_WPS,
84 .active_low = 1,
85 }
86 };
87
88 static void __init dir_300b_init(void)
89 {
90 rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
91
92 rt305x_register_flash(0, &dir_300b_flash_data);
93 rt305x_register_ethernet();
94 ramips_register_gpio_leds(-1, ARRAY_SIZE(dir_300b_leds_gpio),
95 dir_300b_leds_gpio);
96 }
97
98 MIPS_MACHINE(RAMIPS_MACH_DIR_300_REVB, "DIR-300-revB", "D-Link DIR-300 revB",
99 dir_300b_init);