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