1
2
3
4
5
6
7
8
9
10
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/platform_device.h>
14#include <linux/irq.h>
15#include <linux/mtd/physmap.h>
16#include <linux/mv643xx_eth.h>
17#include <linux/leds.h>
18#include <linux/gpio_keys.h>
19#include <linux/input.h>
20#include <linux/i2c.h>
21#include <linux/ata_platform.h>
22#include <asm/mach-types.h>
23#include <asm/gpio.h>
24#include <asm/mach/arch.h>
25#include <mach/orion5x.h>
26#include "common.h"
27#include "mpp.h"
28
29#define MV2120_NOR_BOOT_BASE 0xf4000000
30#define MV2120_NOR_BOOT_SIZE SZ_512K
31
32#define MV2120_GPIO_RTC_IRQ 3
33#define MV2120_GPIO_KEY_RESET 17
34#define MV2120_GPIO_KEY_POWER 18
35#define MV2120_GPIO_POWER_OFF 19
36
37
38
39
40
41static struct mv643xx_eth_platform_data mv2120_eth_data = {
42 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
43};
44
45static struct mv_sata_platform_data mv2120_sata_data = {
46 .n_ports = 2,
47};
48
49static struct mtd_partition mv2120_partitions[] = {
50 {
51 .name = "firmware",
52 .size = 0x00080000,
53 .offset = 0,
54 },
55};
56
57static struct physmap_flash_data mv2120_nor_flash_data = {
58 .width = 1,
59 .parts = mv2120_partitions,
60 .nr_parts = ARRAY_SIZE(mv2120_partitions)
61};
62
63static struct resource mv2120_nor_flash_resource = {
64 .flags = IORESOURCE_MEM,
65 .start = MV2120_NOR_BOOT_BASE,
66 .end = MV2120_NOR_BOOT_BASE + MV2120_NOR_BOOT_SIZE - 1,
67};
68
69static struct platform_device mv2120_nor_flash = {
70 .name = "physmap-flash",
71 .id = 0,
72 .dev = {
73 .platform_data = &mv2120_nor_flash_data,
74 },
75 .resource = &mv2120_nor_flash_resource,
76 .num_resources = 1,
77};
78
79static struct gpio_keys_button mv2120_buttons[] = {
80 {
81 .code = KEY_RESTART,
82 .gpio = MV2120_GPIO_KEY_RESET,
83 .desc = "reset",
84 .active_low = 1,
85 }, {
86 .code = KEY_POWER,
87 .gpio = MV2120_GPIO_KEY_POWER,
88 .desc = "power",
89 .active_low = 1,
90 },
91};
92
93static struct gpio_keys_platform_data mv2120_button_data = {
94 .buttons = mv2120_buttons,
95 .nbuttons = ARRAY_SIZE(mv2120_buttons),
96};
97
98static struct platform_device mv2120_button_device = {
99 .name = "gpio-keys",
100 .id = -1,
101 .num_resources = 0,
102 .dev = {
103 .platform_data = &mv2120_button_data,
104 },
105};
106
107
108
109
110
111static struct orion5x_mpp_mode mv2120_mpp_modes[] __initdata = {
112 { 0, MPP_GPIO },
113 { 1, MPP_GPIO },
114 { 2, MPP_GPIO },
115 { 3, MPP_GPIO },
116 { 4, MPP_GPIO },
117 { 5, MPP_GPIO },
118 { 6, MPP_UNUSED },
119 { 7, MPP_UNUSED },
120 { 8, MPP_GPIO },
121 { 9, MPP_GPIO },
122 { 10, MPP_UNUSED },
123 { 11, MPP_UNUSED },
124 { 12, MPP_SATA_LED },
125 { 13, MPP_SATA_LED },
126 { 14, MPP_SATA_LED },
127 { 15, MPP_SATA_LED },
128 { 16, MPP_UNUSED },
129 { 17, MPP_GPIO },
130 { 18, MPP_GPIO },
131 { 19, MPP_GPIO },
132 { -1 },
133};
134
135static struct i2c_board_info __initdata mv2120_i2c_rtc = {
136 I2C_BOARD_INFO("pcf8563", 0x51),
137 .irq = 0,
138};
139
140static struct gpio_led mv2120_led_pins[] = {
141 {
142 .name = "mv2120:blue:health",
143 .gpio = 0,
144 },
145 {
146 .name = "mv2120:red:health",
147 .gpio = 1,
148 },
149 {
150 .name = "mv2120:led:bright",
151 .gpio = 4,
152 .default_trigger = "default-on",
153 },
154 {
155 .name = "mv2120:led:dimmed",
156 .gpio = 5,
157 },
158 {
159 .name = "mv2120:red:sata0",
160 .gpio = 8,
161 .active_low = 1,
162 },
163 {
164 .name = "mv2120:red:sata1",
165 .gpio = 9,
166 .active_low = 1,
167 },
168
169};
170
171static struct gpio_led_platform_data mv2120_led_data = {
172 .leds = mv2120_led_pins,
173 .num_leds = ARRAY_SIZE(mv2120_led_pins),
174};
175
176static struct platform_device mv2120_leds = {
177 .name = "leds-gpio",
178 .id = -1,
179 .dev = {
180 .platform_data = &mv2120_led_data,
181 }
182};
183
184static void mv2120_power_off(void)
185{
186 pr_info("%s: triggering power-off...\n", __func__);
187 gpio_set_value(MV2120_GPIO_POWER_OFF, 0);
188}
189
190static void __init mv2120_init(void)
191{
192
193 orion5x_init();
194
195 orion5x_mpp_conf(mv2120_mpp_modes);
196
197
198
199
200 orion5x_ehci0_init();
201 orion5x_ehci1_init();
202 orion5x_eth_init(&mv2120_eth_data);
203 orion5x_i2c_init();
204 orion5x_sata_init(&mv2120_sata_data);
205 orion5x_uart0_init();
206 orion5x_xor_init();
207
208 orion5x_setup_dev_boot_win(MV2120_NOR_BOOT_BASE, MV2120_NOR_BOOT_SIZE);
209 platform_device_register(&mv2120_nor_flash);
210
211 platform_device_register(&mv2120_button_device);
212
213 if (gpio_request(MV2120_GPIO_RTC_IRQ, "rtc") == 0) {
214 if (gpio_direction_input(MV2120_GPIO_RTC_IRQ) == 0)
215 mv2120_i2c_rtc.irq = gpio_to_irq(MV2120_GPIO_RTC_IRQ);
216 else
217 gpio_free(MV2120_GPIO_RTC_IRQ);
218 }
219 i2c_register_board_info(0, &mv2120_i2c_rtc, 1);
220 platform_device_register(&mv2120_leds);
221
222
223 if (gpio_request(MV2120_GPIO_POWER_OFF, "POWEROFF") != 0 ||
224 gpio_direction_output(MV2120_GPIO_POWER_OFF, 1) != 0)
225 pr_err("mv2120: failed to setup power-off GPIO\n");
226 pm_power_off = mv2120_power_off;
227}
228
229
230MACHINE_START(MV2120, "HP Media Vault mv2120")
231
232 .phys_io = ORION5X_REGS_PHYS_BASE,
233 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
234 .boot_params = 0x00000100,
235 .init_machine = mv2120_init,
236 .map_io = orion5x_map_io,
237 .init_irq = orion5x_init_irq,
238 .timer = &orion5x_timer,
239 .fixup = tag_fixup_mem32
240MACHINE_END
241