2 * Copyright (C) 2007 Herbert Valerio Riedel <hvr@gnu.org>
3 * Copyright (C) 2008 Martin Michlmayr <tbm@cyrius.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
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>
24 #include <asm/mach/arch.h>
25 #include <asm/arch/orion5x.h>
29 #define MV2120_NOR_BOOT_BASE 0xf4000000
30 #define MV2120_NOR_BOOT_SIZE SZ_512K
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
38 /*****************************************************************************
40 ****************************************************************************/
41 static struct mv643xx_eth_platform_data mv2120_eth_data = {
45 static struct mv_sata_platform_data mv2120_sata_data = {
49 static struct mtd_partition mv2120_partitions[] = {
57 static struct physmap_flash_data mv2120_nor_flash_data = {
59 .parts = mv2120_partitions,
60 .nr_parts = ARRAY_SIZE(mv2120_partitions)
63 static 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,
69 static struct platform_device mv2120_nor_flash = {
70 .name = "physmap-flash",
73 .platform_data = &mv2120_nor_flash_data,
75 .resource = &mv2120_nor_flash_resource,
79 static struct gpio_keys_button mv2120_buttons[] = {
82 .gpio = MV2120_GPIO_KEY_RESET,
87 .gpio = MV2120_GPIO_KEY_POWER,
93 static struct gpio_keys_platform_data mv2120_button_data = {
94 .buttons = mv2120_buttons,
95 .nbuttons = ARRAY_SIZE(mv2120_buttons),
98 static struct platform_device mv2120_button_device = {
103 .platform_data = &mv2120_button_data,
108 /****************************************************************************
110 ****************************************************************************/
111 static struct orion5x_mpp_mode mv2120_mpp_modes[] __initdata = {
112 { 0, MPP_GPIO }, /* Sys status LED */
113 { 1, MPP_GPIO }, /* Sys error LED */
114 { 2, MPP_GPIO }, /* OverTemp interrupt */
115 { 3, MPP_GPIO }, /* RTC interrupt */
116 { 4, MPP_GPIO }, /* V_LED 5V */
117 { 5, MPP_GPIO }, /* V_LED 3.3V */
120 { 8, MPP_GPIO }, /* SATA 0 fail LED */
121 { 9, MPP_GPIO }, /* SATA 1 fail LED */
124 { 12, MPP_SATA_LED }, /* SATA 0 presence */
125 { 13, MPP_SATA_LED }, /* SATA 1 presence */
126 { 14, MPP_SATA_LED }, /* SATA 0 active */
127 { 15, MPP_SATA_LED }, /* SATA 1 active */
129 { 17, MPP_GPIO }, /* Reset button */
130 { 18, MPP_GPIO }, /* Power button */
131 { 19, MPP_GPIO }, /* Power off */
135 static struct i2c_board_info __initdata mv2120_i2c_rtc = {
136 I2C_BOARD_INFO("rtc-pcf8563", 0x51),
140 static void mv2120_power_off(void)
142 pr_info("%s: triggering power-off...\n", __func__);
143 gpio_set_value(MV2120_GPIO_POWER_OFF, 0);
146 static void __init mv2120_init(void)
148 /* Setup basic Orion functions. Need to be called early. */
151 orion5x_mpp_conf(mv2120_mpp_modes);
154 * Configure peripherals.
156 orion5x_ehci0_init();
157 orion5x_ehci1_init();
158 orion5x_eth_init(&mv2120_eth_data);
160 orion5x_sata_init(&mv2120_sata_data);
161 orion5x_uart0_init();
163 orion5x_setup_dev_boot_win(MV2120_NOR_BOOT_BASE, MV2120_NOR_BOOT_SIZE);
164 platform_device_register(&mv2120_nor_flash);
166 platform_device_register(&mv2120_button_device);
168 if (gpio_request(MV2120_GPIO_RTC_IRQ, "rtc") == 0) {
169 if (gpio_direction_input(MV2120_GPIO_RTC_IRQ) == 0)
170 mv2120_i2c_rtc.irq = gpio_to_irq(MV2120_GPIO_RTC_IRQ);
172 gpio_free(MV2120_GPIO_RTC_IRQ);
174 i2c_register_board_info(0, &mv2120_i2c_rtc, 1);
176 /* register mv2120 specific power-off method */
177 if (gpio_request(MV2120_GPIO_POWER_OFF, "POWEROFF") != 0 ||
178 gpio_direction_output(MV2120_GPIO_POWER_OFF, 1) != 0)
179 pr_err("mv2120: failed to setup power-off GPIO\n");
180 pm_power_off = mv2120_power_off;
183 /* Warning: HP uses a wrong mach-type (=526) in their bootloader */
184 MACHINE_START(MV2120, "HP Media Vault mv2120")
185 /* Maintainer: Martin Michlmayr <tbm@cyrius.com> */
186 .phys_io = ORION5X_REGS_PHYS_BASE,
187 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
188 .boot_params = 0x00000100,
189 .init_machine = mv2120_init,
190 .map_io = orion5x_map_io,
191 .init_irq = orion5x_init_irq,
192 .timer = &orion5x_timer,
193 .fixup = tag_fixup_mem32