ramips: rt288x: remove per-board physmap_flash_data instances
[lede.git] / target / linux / ramips / files / arch / mips / ralink / rt288x / mach-f5d8235-v1.c
1 /*
2  *  Belkin F5D825 V1 board support
3  *
4  *  Copyright (C) 2011 Cezary Jackiewicz <cezary.jackiewicz@gmail.com>
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
17 #include <asm/mach-ralink/machine.h>
18 #include <asm/mach-ralink/dev-gpio-buttons.h>
19 #include <asm/mach-ralink/dev-gpio-leds.h>
20 #include <asm/mach-ralink/rt288x.h>
21 #include <asm/mach-ralink/rt288x_regs.h>
22
23 #include "devices.h"
24
25 #include <linux/rtl8366.h>
26 #include <linux/ethtool.h>
27
28 #include <asm/mach-ralink/ramips_eth_platform.h>
29
30 #define F5D8235_GPIO_RTL8366_SCK        2
31 #define F5D8235_GPIO_RTL8366_SDA        1
32
33 #define F5D8235_GPIO_LED_USB_BLUE       7
34 #define F5D8235_GPIO_LED_USB_ORANGE     8
35 #define F5D8235_GPIO_BUTTON_WPS         0
36 #define F5D8235_GPIO_BUTTON_RESET       9
37
38 #define F5D8235_KEYS_POLL_INTERVAL      20
39 #define F5D8235_KEYS_DEBOUNCE_INTERVAL  (3 * F5D8235_KEYS_POLL_INTERVAL)
40
41 static struct mtd_partition f5d8235_partitions[] = {
42         {
43                 .name   = "uboot",
44                 .offset = 0,
45                 .size   = 0x050000,
46                 .mask_flags = MTD_WRITEABLE,
47         }, {
48                 .name   = "kernel and rootfs",
49                 .offset = 0x050000,
50                 .size   = 0x790000,
51         }, {
52                 .name   = "rootfs",
53                 .offset = 0x1D0000,
54                 .size   = 0x610000,
55         }, {
56                 .name   = "nvram",
57                 .offset = 0x7E0000,
58                 .size   = 0x010000,
59         }, {
60                 .name   = "factory",
61                 .offset = 0x7F0000,
62                 .size   = 0x010000,
63         }
64 };
65
66 static struct rtl8366_platform_data f5d8235_rtl8366s_data = {
67         .gpio_sda       = F5D8235_GPIO_RTL8366_SDA,
68         .gpio_sck       = F5D8235_GPIO_RTL8366_SCK,
69 };
70
71 static struct platform_device f5d8235_rtl8366s_device = {
72         .name           = RTL8366S_DRIVER_NAME,
73         .id             = -1,
74         .dev = {
75                 .platform_data  = &f5d8235_rtl8366s_data,
76         }
77 };
78
79 static struct gpio_led f5d8235_leds_gpio[] __initdata = {
80         {
81                 .name           = "f5d8235-v1:blue:storage",
82                 .gpio           = F5D8235_GPIO_LED_USB_BLUE,
83                 .active_low     = 1,
84         },{
85                 .name           = "f5d8235-v1:orange:storage",
86                 .gpio           = F5D8235_GPIO_LED_USB_ORANGE,
87                 .active_low     = 1,
88         }
89 };
90
91 static struct gpio_keys_button f5d8235_gpio_buttons[] __initdata = {
92         {
93                 .desc           = "reset",
94                 .type           = EV_KEY,
95                 .code           = KEY_RESTART,
96                 .debounce_interval = F5D8235_KEYS_DEBOUNCE_INTERVAL,
97                 .gpio           = F5D8235_GPIO_BUTTON_RESET,
98                 .active_low     = 1,
99         }, {
100                 .desc           = "wps",
101                 .type           = EV_KEY,
102                 .code           = KEY_WPS_BUTTON,
103                 .debounce_interval = F5D8235_KEYS_DEBOUNCE_INTERVAL,
104                 .gpio           = F5D8235_GPIO_BUTTON_WPS,
105                 .active_low     = 1,
106         }
107 };
108
109 static void __init f5d8235_init(void)
110 {
111         rt288x_gpio_init(RT2880_GPIO_MODE_UART0 | RT2880_GPIO_MODE_I2C);
112
113         rt288x_flash0_data.nr_parts = ARRAY_SIZE(f5d8235_partitions);
114         rt288x_flash0_data.parts = f5d8235_partitions;
115         rt288x_register_flash(0);
116
117         rt288x_register_wifi();
118         rt288x_register_wdt();
119
120         ramips_register_gpio_leds(-1, ARRAY_SIZE(f5d8235_leds_gpio),
121                                   f5d8235_leds_gpio);
122
123         ramips_register_gpio_buttons(-1, F5D8235_KEYS_POLL_INTERVAL,
124                                      ARRAY_SIZE(f5d8235_gpio_buttons),
125                                      f5d8235_gpio_buttons);
126
127         platform_device_register(&f5d8235_rtl8366s_device);
128
129         rt288x_eth_data.speed = SPEED_1000;
130         rt288x_eth_data.duplex = DUPLEX_FULL;
131         rt288x_eth_data.tx_fc = 1;
132         rt288x_eth_data.rx_fc = 1;
133         rt288x_register_ethernet();
134 }
135
136 MIPS_MACHINE(RAMIPS_MACH_F5D8235_V1, "F5D8235_V1",
137              "Belkin F5D8235 v1", f5d8235_init);